python-exceptiongroup
Port variant v15
Summary Backport of PEP 654 (exception groups) (3.15)
Package version 1.3.2
Homepage https://pypi.org/project/exceptiongroup/
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v14
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 23 NOV 2026, 05:55:02 UTC
Port created 06 APR 2022, 02:12:22 UTC
Subpackage Descriptions
single :alt: Build Status :alt: Code Coverage :alt: Tidelift This is a backport of the BaseExceptionGroup and ExceptionGroup classes from Python 3.11. It contains the following: * The ``exceptiongroup.BaseExceptionGroup and exceptiongroup.ExceptionGroup`` classes * A utility function (``exceptiongroup.catch()``) for catching exceptions possibly nested in an exception group * Patches to the TracebackException class that properly formats exception groups (installed on import) * An exception hook that handles formatting of exception groups through TracebackException (installed on import) * Special versions of some of the functions from the traceback module, modified to correctly handle exception groups even when monkey patching is disabled, or blocked by another custom exception hook: * ``traceback.format_exception()`` * ``traceback.format_exception_only()`` * ``traceback.print_exception()`` * ``traceback.print_exc()`` * A backported version of ``contextlib.suppress()`` from Python 3.12.1 which also handles suppressing exceptions inside exception groups If this package is imported on Python 3.11 or later, the built-in implementations of the exception group classes are used instead, TracebackException is not monkey patched and the exception hook won't be installed. See the `standard library documentation`_ for more information on exception groups. .. _standard library documentation: https://docs.python.org/3/library/exceptions.html License ======= This project includes code under the MIT License and code copied from the Python standard library under the Python Software Foundation License Version 2. The full notices and terms for both licenses are in the LICENSE file. Catching exceptions =================== Due to the lack of the ``except*`` syntax introduced by `PEP 654`_ in earlier Python versions, you need to use ``exceptiongroup.catch()`` to catch exceptions that are potentially nested inside an exception group. This function returns a context manager that calls the given handler for any exceptions matching the sole argument. The argument to ``catch()`` must be a dict (or any Mapping) where each key is either an exception class or an iterable of exception classes. Each value must be a callable that takes a single positional argument. The handler will be called at most once, with an exception group as an argument which will contain all the exceptions that are any of the given types, or their subclasses. The exception group may contain nested groups containing more matching exceptions. Thus, the following Python 3.11+ code: .. code-block:: python try: ... except* (ValueError, KeyError) as excgroup: for exc in excgroup.exceptions: print('Caught exception:', type(exc)) except* RuntimeError: print('Caught runtime error') would be written with this backport like this: .. code-block:: python from exceptiongroup import BaseExceptionGroup, catch def value_key_err_handler(excgroup: BaseExceptionGroup) -> None: for exc in excgroup.exceptions: print('Caught exception:', type(exc))
Configuration Switches (platform-specific settings discarded)
PY314 OFF Build using Python 3.14 PY315 ON Build using Python 3.15
Package Dependencies by Type
Build (only) python315:dev:std
python-pip:single:v15
autoselect-python:single:std
Build and Runtime python315:primary:std
Download groups
main mirror://PYPIWHL/a0/7d/0fb19ccdf794c448141461180d5992c50402f69f8515a801bfac7ad65f45
Distribution File Information
41c6a70dfec22050d3d8b43386b059a4dc0bca3f3d40a40971cb206fff1785af 16854 python-src/exceptiongroup-1.3.2-py3-none-any.whl
Ports that require python-exceptiongroup:v15
No other ports depend on this one.