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.
pip install zope-exceptionsVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to 3.9 or newer, or pin `zope-exceptions<6.0` if you cannot upgrade Python.
Ensure your `setuptools` is up-to-date and your environment correctly handles PEP 420 native namespace packages. Consider using modern virtual environment tools.
Upgrade your Python environment to 3.7 or newer, or pin `zope-exceptions<5.0` if you are on an unsupported Python version.
For expensive context generation, use `__traceback_supplement__` instead. This variable takes a callable and its arguments, which are only evaluated if a traceback needs to be formatted, delaying the computation.
When working with Zope, understand the specific exception handling mechanism for your Zope version (e.g., configuring exception views in ZCML for Zope 4+). `zope.errorview` is a related package that provides basic HTTP and Browser views for common exceptions in newer Zope versions.
Ensure your Python environment uses `setuptools` compatible with PEP 420 native namespace packages. Upgrade `setuptools` to its latest version (`pip install --upgrade setuptools`) and consider using a fresh virtual environment.
Assign `__traceback_supplement__` a tuple `(my_callable, arg1, arg2, ...)` where `my_callable` is the function to be called, not `my_callable(arg1, arg2, ...)`. The function will be called only when the traceback is formatted.
Refactor your code to raise proper exception classes, such as `raise ValueError('My Error')`.No dependency data recorded yet.