PEP-654: clarify that BaseExceptionGroup is the factory function that… (GH-2203)
This commit is contained in:
parent
b07248305b
commit
f2f542d544
14
pep-0654.rst
14
pep-0654.rst
|
@ -150,12 +150,14 @@ fields ``message`` and ``exceptions``. For example:
|
||||||
``ExceptionGroup('issues', [ValueError('bad value'), TypeError('bad type')])``.
|
``ExceptionGroup('issues', [ValueError('bad value'), TypeError('bad type')])``.
|
||||||
The difference between them is that ``ExceptionGroup`` can only wrap
|
The difference between them is that ``ExceptionGroup`` can only wrap
|
||||||
``Exception`` subclasses while ``BaseExceptionGroup`` can wrap any
|
``Exception`` subclasses while ``BaseExceptionGroup`` can wrap any
|
||||||
``BaseException`` subclass. A factory method that inspects the nested
|
``BaseException`` subclass. The ``BaseExceptionGroup`` constructor
|
||||||
exceptions and selects between ``ExceptionGroup`` and ``BaseExceptionGroup``
|
inspects the nested exceptions and if they are all ``Exception`` subclasses,
|
||||||
makes the choice automatic. In the rest of the document, when we refer to
|
it returns an ``ExceptionGroup`` rather than a ``BaseExceptionGroup``. The
|
||||||
an exception group, we mean either an ``ExceptionGroup`` or a
|
``ExceptionGroup`` constructor raises a ``TypeError`` if any of the nested
|
||||||
``BaseExceptionGroup``. When it is necessary to make the distinction, we
|
exceptions is not an ``Exception`` instance. In the rest of the document,
|
||||||
use the class name. For brevity, we will use ``ExceptionGroup`` in code
|
when we refer to an exception group, we mean either an ``ExceptionGroup``
|
||||||
|
or a ``BaseExceptionGroup``. When it is necessary to make the distinction,
|
||||||
|
we use the class name. For brevity, we will use ``ExceptionGroup`` in code
|
||||||
examples that are relevant to both.
|
examples that are relevant to both.
|
||||||
|
|
||||||
Since an exception group can be nested, it represents a tree of exceptions,
|
Since an exception group can be nested, it represents a tree of exceptions,
|
||||||
|
|
Loading…
Reference in New Issue