Skip to main content

tbtrim

PyPI - Downloads PyPI - Version PyPI - Format PyPI - Python Version PyPI - Status Travis CI - Status License

tbtrim is a utility to trim Python traceback information. By assigning user-refined sys.excepthook, one can easily customize the behavior after an exception is raise and uncaught, and just before the interpreter prints out the given traceback and exception to sys.stderr.

In a more human-readable way, tbtrim is to let you handle the last words of a program when it exits because of an exception.

Installation

Simply run the following to install the current version from PyPI:

$ pip install tbtrim

Or install the latest version from the git repository:

git clone https://github.com/gousaiyang/tbtrim.git
cd tbtrim
pip install -e .
# and to update at any time
git pull

Usage

set_trim_rule(predicate, target=BaseException, exclude=None, strict=False, exception=None)

Set the rule for trimming traceback (will set sys.excepthook and threading.excepthook if available).

You can determine whether to start trimming traceback items based on the filename (using predicate), and can choose to trim traceback only for some certain exceptions (using target and exclude).

Args:

  • predicate (function): a function which takes one str parameter (the filename of a traceback item) and returns bool (returning True indicates that this traceback item and the following items should be trimmed)
  • target (class_or_tuple): an exception or a tuple of exceptions may be given to trim traceback only for those exceptions
  • exclude (class_or_tuple): an exception or a tuple of exceptions may be given to exclude them from traceback trimming
  • strict (bool): indicate whether to check an exception against target and exclude in a strict mode (setting True uses is to check, False uses issubclass to check)
  • exception (class_or_tuple): this is a deprecated alias of exclude, retained for backward compatibility

clear_trim_rule()

Clear the rule for trimming traceback (restore the excepthooks).

Metadata

Release files for tbtrim 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tbtrim 0.3.1
File Size Uploaded Provenance Actions
tbtrim-0.3.1.tar.gz 3.5 kB Without provenance Details for tbtrim-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tbtrim 0.3.1
File Interpreter ABI Platform Actions
tbtrim-0.3.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for tbtrim-0.3.1-py2.py3-none-any.whl

Total release size: 7.9 kB

Release files / tbtrim-0.3.1.tar.gz

Download URL tbtrim-0.3.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b6285ac02e9a7b78fab97de65668fe2def0f5d8783b0e0dfcb4b7c0a635b3d11
BLAKE2b-256 checksum
How to use checksums
856289756f5d2d61691591c4293fd4cc1fbb3aab1466251c7319fe60dd08fb27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release files / tbtrim-0.3.1-py2.py3-none-any.whl

Download URL tbtrim-0.3.1-py2.py3-none-any.whl
Size 4.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
48265ad3aeee3bfcc6f0972f6fad623bd99302dce616e1d451663649b50fde19
BLAKE2b-256 checksum
How to use checksums
072161b192799083492255efc53950ba47317087e1a3d2b5e767c29f71c8c4ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Security for tbtrim 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page