From f2f542d54442d7304b95ff6652ec89b6e6a2d45b Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Mon, 27 Dec 2021 21:51:08 +0000 Subject: [PATCH] =?UTF-8?q?PEP-654:=20clarify=20that=20BaseExceptionGroup?= =?UTF-8?q?=20is=20the=20factory=20function=20that=E2=80=A6=20(GH-2203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pep-0654.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pep-0654.rst b/pep-0654.rst index a43eb754e19..3a16b64d9d1 100644 --- a/pep-0654.rst +++ b/pep-0654.rst @@ -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,