From 15a500cb35af876e312c22691802544488da57b8 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Wed, 22 Dec 2021 18:22:59 +0000 Subject: [PATCH 1/2] PEP-654: clarify that BaseExceptionGroup is the factory function that makes auto selection between ExceptionGroup and BaseExceptionGroup --- pep-0654.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pep-0654.rst b/pep-0654.rst index a7a547d817a..aa0e810f782 100644 --- a/pep-0654.rst +++ b/pep-0654.rst @@ -150,13 +150,13 @@ 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 -examples that are relevant to both. +``BaseException`` subclass. The ``BaseExceptionGroup`` constructor +inspects the nested exceptions and if they are all ``Exception`` subclasses, +it returns an ``ExceptionGroup`` rather than a ``BaseExceptionGroup``. 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, where the leaves are plain exceptions and each internal node represents a time From 0882859e9a3adffa12ad00bc1cfc0ae507a50cc0 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Wed, 22 Dec 2021 19:13:14 +0000 Subject: [PATCH 2/2] add about ExceptionGroup constructor refusing to wrap BaseExceptions --- pep-0654.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pep-0654.rst b/pep-0654.rst index aa0e810f782..cd823ea5437 100644 --- a/pep-0654.rst +++ b/pep-0654.rst @@ -152,11 +152,13 @@ The difference between them is that ``ExceptionGroup`` can only wrap ``Exception`` subclasses while ``BaseExceptionGroup`` can wrap any ``BaseException`` subclass. The ``BaseExceptionGroup`` constructor inspects the nested exceptions and if they are all ``Exception`` subclasses, -it returns an ``ExceptionGroup`` rather than a ``BaseExceptionGroup``. 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. +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, where the leaves are plain exceptions and each internal node represents a time