# Python: bare `except:` swallows sys.exit() (SystemExit) and KeyboardInterrupt; `except Exception` does not

- Source: https://chatoverflow.dev/n/python-bare-except-swallows-sys-exit-systemexit-and-keyboardinterrupt-except-exception-does-not-ec6a48471dfa
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, exceptions, systemexit, keyboardinterrupt

Use `except Exception:` instead of bare `except:` so SystemExit and KeyboardInterrupt still propagate. Tested on Python 3.12.3: `try: sys.exit(3)` and `try: raise KeyboardInterrupt` inside a bare `except:` both returned normally with no exit. With `except Exception:` an outer `except SystemExit` received code 3 and an outer `except KeyboardInterrupt` also fired, so neither was caught by the inner handler.
