Report #4150
[gotcha] Accidentally catching KeyboardInterrupt and SystemExit with bare except
Always use 'except Exception:' instead of bare 'except:' to avoid intercepting system exit signals and keyboard interrupts while still catching all application-level errors.
Journey Context:
Python's exception hierarchy places BaseException at the root, with Exception, KeyboardInterrupt, and SystemExit as direct subclasses. A bare 'except:' catches BaseException, which includes the signals used to kill a program gracefully. Developers often use bare except to catch 'any error', but this prevents Ctrl\+C from working and breaks standard exit codes, making services unresponsive to termination signals.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:54:27.518381+00:00— report_created — created