Skip to main content

Debug exceptions offline by saving them to a dump and raising them at a later point.

Project description

Traceback Serializer Project (offline-debug)

PyPI version Tests Coverage Ruff Ty checked

Overview

A Python package for high-fidelity serialization and deserialization of exceptions and their complete tracebacks. Unlike other solutions, offline-debug reconstructs actual types.FrameType objects using the Python C API, ensuring that re-raised exceptions look and feel genuine to debuggers and introspection tools.

Core Functions

  • save_traceback(exc: Exception, file_path: str): Serializes an exception, its traceback, and all picklable local/global variables to a binary file.
  • load_traceback(file_path: str) -> typing.Never: Loads the serialized state, reconstructs the exception and its full traceback chain (including __cause__ and __context__), and raises it.

Technical Implementation

  • True Frame Reconstruction: Uses ctypes to call PyFrame_New from the Python C API. This creates real frame objects which are required for a valid types.TracebackType.
  • Python 3.13 Compatibility: Leverages PEP 667 features where f_locals is a write-through proxy, allowing for accurate local variable restoration.
  • Robust Serialization:
    • pickle is used for exceptions and variables.
    • marshal is used for code objects.
    • Non-picklable items are gracefully handled by storing their repr.

Development & Tooling

  • Package Manager: uv
  • Minimum Python: 3.12
  • Testing: pytest
  • Commands:
    • Add dependencies: uv add <package>
    • Run tests: uv run pytest

Usage Example

from offline_debug import save_traceback, load_traceback

try:
    # Code that might fail
    some_complex_operation()
except Exception as e:
    save_traceback(e, "crash_report.dump")

# To debug or re-examine later:
load_traceback("crash_report.dump")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

offline_debug-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

offline_debug-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file offline_debug-0.1.0.tar.gz.

File metadata

  • Download URL: offline_debug-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for offline_debug-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b9da3fa6e642b34a402f53567201510557f4057e7bec7b5a94615e9fa26d0c7
MD5 9e01c818a600a29e54df43446c67ce50
BLAKE2b-256 48f6a60014b25824152e4ea782720fac743456e2b9f89afc150cdee574b77926

See more details on using hashes here.

Provenance

The following attestation bundles were made for offline_debug-0.1.0.tar.gz:

Publisher: ci.yml on INTODAN/offline-debug

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file offline_debug-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: offline_debug-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for offline_debug-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98c064b63793c9dbc0d0679aa4dff63366c7a1a3ddfe75bbdf7b22b357bde674
MD5 35b7b60cc58be8b3613943c0ba1df643
BLAKE2b-256 362977b23213b12bc97f4b3ea0f0e0fa3c3439e88f7cac501c9a230f9dd4adc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for offline_debug-0.1.0-py3-none-any.whl:

Publisher: ci.yml on INTODAN/offline-debug

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page