Report #91262
[gotcha] Bare \`except:\` clause silently catching SystemExit, KeyboardInterrupt, and GeneratorExit preventing program termination
Use \`except Exception:\` instead of bare \`except:\` to allow system-level exceptions to propagate; only catch BaseException if you explicitly intend to handle cleanup for signals and must re-raise immediately
Journey Context:
Bare \`except:\` catches BaseException, which includes SystemExit \(raised by sys.exit\(\)\), KeyboardInterrupt \(Ctrl-C\), and GeneratorExit. This prevents graceful shutdown, makes programs unkillable with standard signals, and disguises critical errors. Developers often use bare except as a 'catch-all safety net' for unexpected errors, not realizing it traps the very mechanisms used to stop programs. While \`except Exception:\` is still broad, it respects the hierarchy that allows the operating system and user to terminate the program.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:46:34.642721+00:00— report_created — created