You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ExceptionGroup repr is misleading if original exception sequence is mutated #141732
The exception listing in repr(exc_grp) diverges from exc_grp.exceptions when the initial sequence of exceptions passed to the constructor has been mutated.
Expected behavior: The exceptions listed in repr(exc_grp) match exc_grp.exceptions, which is immutable.
On CPython, it looks like BaseExceptionGroup.__repr__ resolves to BaseException.__repr__, so the repr ends up using self.args[1] instead of self.exceptions.
I skimmed the PEP and didn't see anything that indicated that either repr implementation is in violation of the PEP.
I skimmed the PEP and didn't see anything that indicated that either repr implementation is in violation of the PEP.
The PEP does reference the repr() of ExceptionGroups but not explicitly specify anything:
>>>try:
... raiseExceptionGroup("problem", [BlockingIOError()])
... except* OSErrorase: # Would catch the error
... print(repr(e))
... except*BlockingIOError: # Would never run
... print('never')
...
ExceptionGroup('problem', [BlockingIOError()])
But I agree that mutating an argument which is only used to create an immutable tuple shouldn't change the repr.
Activity
gschaffner commentedon Nov 19, 2025
I noticed that PyPy behaves the way I expected here; they use
self.exceptionsinBaseExceptionGroup.__repr__instead ofself.args[1]:https://github.com/pypy/pypy/blob/release-pypy3.11-v7.3.20/pypy/module/exceptions/app_group.py#L92-L93
On CPython, it looks like
BaseExceptionGroup.__repr__resolves toBaseException.__repr__, so the repr ends up usingself.args[1]instead ofself.exceptions.I skimmed the PEP and didn't see anything that indicated that either repr implementation is in violation of the PEP.
dr-carlos commentedon Nov 19, 2025
The PEP does reference the
repr()ofExceptionGroups but not explicitly specify anything:But I agree that mutating an argument which is only used to create an immutable tuple shouldn't change the repr.
serhiy-storchaka commentedon Nov 19, 2025
This may be a part of more complex problem. See #137889.
gh-141732: Fix `ExceptionGroup` repr changing when original exception…
pythongh-141732: Fix `ExceptionGroup` repr changing when original exc…
[3.13] gh-141732: Fix ExceptionGroup repr changing when original exce…
hugovk commentedon Feb 3, 2026
This has been merged in
mainand 3.13 but cannot be merged for 3.14 because of failing CI: #142388.Please can you check the backport?
dr-carlos commentedon Feb 3, 2026
Yes, will do!
Opened #144445
python3Packages.exceptiongroup: fix build on staging
python3Packages.exceptiongroup: fix build on staging
python3Packages.exceptiongroup: fix build on staging
python3Packages.exceptiongroup: fix build after cpython repr changes
python3Packages.exceptiongroup: fix build after cpython repr changes
python3Packages.exceptiongroup: fix build after cpython repr changes
[3.14] gh-141732: Fix ExceptionGroup repr changing when original exce…