[New-bugs-announce] [issue46729] Better str() for BaseExceptionGroup

Irit Katriel report at bugs.python.org
Sat Feb 12 06:02:01 EST 2022

New submission from Irit Katriel <iritkatriel at gmail.com>:

The str() of exception groups currently contains just the msg as passed to the constructor. This turned out to be confusing (see https://github.com/python/cpython/pull/31270#issuecomment-1036418346).

We should consider whether it is possible to design a more informative str().

Note that the str() is included in the standard traceback, which include the line:

f"{type(e)}: {str(e)}"

So str() should not repeat the type, and should not clutter this too much. Probably just the msg plus the number of contained leaf exceptions.

PEP 654 needs to be updated with what we do here, and the change needs to be approved by the SC.

components: Interpreter Core
keywords: 3.2regression
messages: 413121
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: Better str() for BaseExceptionGroup
versions: Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list