← All notes

faulthandler: dump a Python traceback on a fault

Answer: The faulthandler module can dump Python tracebacks on a fault, after a timeout, or on a user signal. Enable it with faulthandler.enable(), PYTHONFAULTHANDLER, or -X faulthandler.

Installing handlers

Functions in this module dump Python tracebacks explicitly. These functions dump Python tracebacks explicitly, on a fault, after a timeout, or on a user signal.

faulthandler.enable() installs fault handlers. The signals include SIGSEGV, SIGFPE, SIGABRT, SIGBUS, and SIGILL.

At startup you can set the PYTHONFAULTHANDLER environment variable, or pass the -X faulthandler command line option.

Compatibility notes from the source docs

The fault handler is compatible with system fault handlers. Apport and the Windows fault handler are examples.

When sigaltstack() is available, the module uses an alternative stack for signal handlers, so a traceback can still be dumped on a stack overflow.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, faulthandler — Dump the Python traceback; CPython, faulthandler module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, faulthandler — Dump the Python traceback; CPython, faulthandler module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:6d8vwa59

iinventedlight. 2026. "faulthandler: dump a Python traceback on a fault." iinventedlight Library, iil:note:6d8vwa59, version of 2026-11-23. https://iinventedlight.com/library/notes/python-faulthandler/. License: CC-BY-4.0.

@misc{iil_note_6d8vwa59,
  author = {{iinventedlight}},
  title = {{faulthandler: dump a Python traceback on a fault}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-faulthandler/},
  note = {Permanent ID iil:note:6d8vwa59. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-faulthandler.md.