Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP-654: clarify that BaseExceptionGroup is the factory function that… #2203

Merged
merged 2 commits into from
Dec 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions pep-0654.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ fields ``message`` and ``exceptions``. For example:
``ExceptionGroup('issues', [ValueError('bad value'), TypeError('bad type')])``.
The difference between them is that ``ExceptionGroup`` can only wrap
``Exception`` subclasses while ``BaseExceptionGroup`` can wrap any
``BaseException`` subclass. A factory method that inspects the nested
exceptions and selects between ``ExceptionGroup`` and ``BaseExceptionGroup``
makes the choice automatic. In the rest of the document, 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
``BaseException`` subclass. The ``BaseExceptionGroup`` constructor
inspects the nested exceptions and if they are all ``Exception`` subclasses,
it returns an ``ExceptionGroup`` rather than a ``BaseExceptionGroup``. The
``ExceptionGroup`` constructor raises a ``TypeError`` if any of the nested
exceptions is not an ``Exception`` instance. In the rest of the document,
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.

Since an exception group can be nested, it represents a tree of exceptions,
Expand Down