Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
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.
Reproducer:
exceptions=list[Exception]() exceptions.append(ValueError()) exc_grp=ExceptionGroup("", exceptions) print(f"{exc_grp.exceptions=!r}") print(f"{exc_grp=!r}") print() exceptions.clear() print(f"{exc_grp.exceptions=!r}") print(f"{exc_grp=!r}")Output:
exc_grp.exceptions=(ValueError(),) exc_grp=ExceptionGroup('', [ValueError()]) exc_grp.exceptions=(ValueError(),) exc_grp=ExceptionGroup('', []) Expected output:
exc_grp.exceptions=(ValueError(),) exc_grp=ExceptionGroup('', [ValueError()]) exc_grp.exceptions=(ValueError(),) exc_grp=ExceptionGroup('', [ValueError()]) CPython versions tested on:
3.11, 3.12, 3.13, 3.14
Operating systems tested on:
Linux
Linked PRs
- gh-141732: Fix
ExceptionGrouprepr changing when original exception sequence is mutated #141736 - [3.14] gh-141732: Fix
ExceptionGrouprepr changing when original exception sequence is mutated (GH-141736) #142388 - [3.13] gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (GH-141736) #142391
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error