Registry / testing / zope-exceptions

zope-exceptions

JSON →
library6.0pypypi✓ verified 35d ago

This package provides general-purpose exception classes and implementations for the Zope ecosystem, designed to extend Python's standard `traceback` module with additional context information. It facilitates annotating tracebacks with `__traceback_info__` for unstructured data or `__traceback_supplement__` for delayed, structured data. It is currently at version 6.0 and receives updates primarily driven by Python version support and significant ecosystem changes, maintaining an active but irregular release cadence.

testing
Install & Compatibility
Where this runs
tested against v6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.059s · 19.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.1s · import 0.057s · 21MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from zope.exceptions import format_exception

Used for advanced HTML-based traceback formatting.

from zope.exceptions.exceptionformatter import HTMLExceptionFormatter

Used for advanced plain-text traceback formatting.

from zope.exceptions.exceptionformatter import TextExceptionFormatter

This quickstart demonstrates how to use `__traceback_info__` to inject context into an exception's traceback. The `format_exception` function then processes this enriched information for output, making debugging easier.

import sys from zope.exceptions import format_exception def problematic_function(item_id): __traceback_info__ = f"Processing item with ID: {item_id}" # Adds context to traceback raise ValueError(f"Failed to process item {item_id}") try: problematic_function('XYZ-123') except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() formatted_traceback = format_exception(exc_type, exc_value, exc_traceback) print("\n".join(formatted_traceback)) del exc_traceback # Avoid reference cycles
Debug
Known footguns
breakingVersion 6.0 and higher explicitly drop support for Python 3.8 and older. Ensure your project runs on Python 3.9 or newer.
breakingVersion 6.0 replaces `pkg_resources` namespace with PEP 420 native namespace for package discovery. This can impact environments relying on older `setuptools` or specific packaging setups.
breakingVersion 5.0 dropped support for Python 2.7, 3.5, and 3.6.
gotchaThe `__traceback_info__` variable is evaluated immediately, even if the traceback is never formatted. If generating this information is computationally expensive, it can introduce unnecessary runtime overhead.
gotchaIn older Zope 2.x environments, error handling often involved `standard_error_message` (a ZODB object). Zope 3/4 and modern WSGI setups transitioned to 'exception views' registered via ZCML. `zope.exceptions` provides low-level tools, but the high-level application error display depends on the broader Zope architecture.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
20 hits · last 30 days
dotbot
4
gptbot
4
ahrefsbot
3
script
1
mj12bot
1
Resources