# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-exceptiongroup VERSION= 1.0.0rc4 KEYWORDS= python VARIANTS= py39 py310 SDESC[py310]= Backport of PEP 654 (exception groups) (3.10) SDESC[py39]= Backport of PEP 654 (exception groups) (3.9) HOMEPAGE= none CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/40/f6/d04b98165dca52470033c3999afc9c67c22d970dc9bf6b719cec09455eab DISTFILE[1]= exceptiongroup-1.0.0rc4-py3-none-any.whl:main DF_INDEX= 1 SPKGS[py310]= single SPKGS[py39]= single OPTIONS_AVAILABLE= PY39 PY310 OPTIONS_STANDARD= none VOPTS[py310]= PY39=OFF PY310=ON VOPTS[py39]= PY39=ON PY310=OFF DISTNAME= exceptiongroup-1.0.0rc4.dist-info GENERATED= yes [PY39].USES_ON= python:py39,wheel [PY310].USES_ON= python:py310,wheel [FILE:2909:descriptions/desc.single] :alt: Build Status :alt: Code Coverage 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) 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 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 which is the exception object to be handled. Thus, the following Python 3.11+ code: .. code-block:: python3 try: ... except* (ValueError, KeyError) as exc: print('Caught exception:', type(exc)) except* RuntimeError: print('Caught runtime error') would be written with this backport like this: .. code-block:: python3 from exceptiongroup import catch def value_key_err_handler(exc: Exception) -> None: print('Caught exception:', type(exc)) def runtime_err_handler(exc: RuntimeError) -> None: print('Caught runtime error') with catch({ (ValueError, KeyError): value_key_err_handler, RuntimeError: runtime_err_handler }): ... **NOTE**: Just like with ``except*``, you cannot handle BaseExceptionGroup or ExceptionGroup with ``catch()``. Notes on monkey patching ======================== To make exception groups render properly when an unhandled exception group is being printed out, this package does two things when it is imported on any Python version earlier than 3.11: #. The ``traceback.TracebackException`` class is monkey patched to store extra information about exception groups (in ``__init__()``) and properly format them (in ``format()``) #. An exception hook is installed at ``sys.excepthook``, provided that no other hook is [FILE:119:distinfo] 21739e657be44a7298757e21227726ed4553e62b3ccb0be9ca5c51a2707d0f52 10545 exceptiongroup-1.0.0rc4-py3-none-any.whl