Skip to content

fix: replace 8 bare except:pass clauses with specific exception handling (fixes #115)#135

Open
charlesaurav13 wants to merge 1 commit into
BusKill:masterfrom
charlesaurav13:fix/115-bare-except-clauses
Open

fix: replace 8 bare except:pass clauses with specific exception handling (fixes #115)#135
charlesaurav13 wants to merge 1 commit into
BusKill:masterfrom
charlesaurav13:fix/115-bare-except-clauses

Conversation

@charlesaurav13

Copy link
Copy Markdown

Summary

Eight bare except: pass clauses in buskill/__init__.py were silently swallowing all exceptions, including KeyboardInterrupt and SystemExit. This made debugging nearly impossible and prevented clean shutdown via Ctrl+C.

Changes

Location Before After
__del__usb_handler.join() except: pass except Exception as e: logger.debug(...)
__del__upgrade_process.join() except: pass except Exception as e: logger.debug(...)
__del__wipeCache() except: pass except Exception as e: logger.debug(...)
setupDataDir — DATA_DIR log except: except Exception as e:
toggle() disarm — usb_handler kill/join except: pass except Exception as e: logger.debug(...)
wipeCache()umount except: pass except Exception as e: logger.debug(...)
wipeCache()makedirs/chmod except: pass except Exception as e: logger.debug(...)
doUpgrade — KEYS file fallback except: except FileNotFoundError: (narrowed to the one expected failure mode)

All cleanup-path exceptions are now logged at DEBUG level instead of being silently dropped. KeyboardInterrupt and SystemExit are no longer swallowed.

Test plan

  • Verify Ctrl+C terminates the process cleanly
  • Verify existing behaviour unchanged for normal arm/disarm cycles
  • Confirm exception messages appear in debug log when cleanup fails

Closes #115

Fixes BusKill#115. Eight bare except: pass clauses were silently swallowing
all exceptions including KeyboardInterrupt and SystemExit, making
debugging nearly impossible and preventing clean shutdown via Ctrl+C.

Changes:
- Cleanup path (usb_handler.join, upgrade_process.join, wipeCache):
  catch Exception and log at DEBUG level so failures are visible
- toggle() disarm path: same pattern for usb_handler kill/join
- wipeCache() umount and makedirs: log at DEBUG level
- KEYS file fallback: narrow to FileNotFoundError since only a missing
  file should trigger the fallback; other errors should propagate

Signed-off-by: charlesaurav13 <sauravp1236@gmail.com>
@github-actions

Copy link
Copy Markdown

INFO: No unicode characters found in PR's commits

(source)

@maltfield

Copy link
Copy Markdown
Member

Thanks for the PR :)

Please note that this repo does not accept contributions that use AI

Can you please tell us if you wrote this code, comments, and PR contents entirely by yourself? Or if you used AI for any part of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: 8 bare except:pass clauses silently swallowing all errors across buskill/__init__.py

2 participants