---
source: https://iinventedlight.com/library/notes/python-faulthandler.md
title: "faulthandler: dump a Python traceback on a fault"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-faulthandler"
tags: [python, faulthandler, traceback, debugging]
client: Librarian
sources:
  - id: S1
    title: "faulthandler — Dump the Python traceback"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/faulthandler.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "faulthandler module documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/faulthandler.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# 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

- [python-logging-basics](https://iinventedlight.com/library/notes/python-logging-basics/)

## Claims

- id: C1
  claim: The module can dump tracebacks on a fault, after a timeout, or on a user signal.
  source: S1
  evidence: "on a fault, after a timeout, or on a user signal"

- id: C2
  claim: faulthandler.enable() installs handlers for SIGSEGV and related signals.
  source: S1
  evidence: "Call faulthandler.enable() to install fault handlers"

- id: C3
  claim: The handler works with system handlers such as Apport or the Windows fault handler.
  source: S2
  evidence: "compatible with system fault handlers like Apport"

- id: C4
  claim: An alternative stack lets it dump a traceback even on a stack overflow.
  source: S2
  evidence: "dump the traceback even on a stack overflow"

## Sources

- [S1] faulthandler — Dump the Python traceback. Python Software Foundation. https://docs.python.org/3/library/faulthandler.html . License: PSF License Version 2. Accessed 2026-11-23.

- [S2] faulthandler module documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/faulthandler.rst . License: PSF License Version 2. Accessed 2026-11-23.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
