python runtime_error official true

SystemExit

ID: python/systemexit

Also available as: JSON · Markdown
80%Fix Rate
95%Confidence
0Evidence

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

sys.exit() was called. The program is terminating normally with the specified exit code.

generic

Official Documentation

https://docs.python.org/3/library/exceptions.html

Workarounds

  1. 90% success If you need to prevent exit, catch SystemExit specifically (not Exception)
    except SystemExit as e: if e.code != 0: logging.warning('Exit with %s', e.code)

Dead Ends

Common approaches that don't work:

  1. Catching SystemExit to prevent program exit 80% fail

    Prevents intentional shutdown; may cause hung processes