Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
GH-146096: Fix base exception group repr#146141
Conversation
dr-carlos commentedMar 18, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the fix@sergey-miryanov! All looks good to me. It's a pity that we don't preserve the list-like repr ( |
| * with self.exceptions. Instead, use self.exceptions for accuracy, | ||
| * making it look like self.args[1] for backwards compatibility. */ | ||
| if (PyList_Check(PyTuple_GET_ITEM(self->args, 1))) { | ||
| if (PyTuple_GET_SIZE(self->args) == 2 &&PyList_Check(PyTuple_GET_ITEM(self->args, 1))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Do we need to check that it's a Tuple first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No,args is always converted to a tuple in its setter:
https://github.com/sergey-miryanov/cpython/blob/4f9a6ba7ba98a83d5594aacadcddb90696ffd5d7/Objects/exceptions.c#L351-L364
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Could add an assert just so it reads like it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done
sergey-miryanov commentedMar 19, 2026
I'm not sure that failed test related to change. |
ced6460 intopython:mainUh oh!
There was an error while loading.Please reload this page.
sergey-miryanov commentedMar 19, 2026
Thanks all! |
Uh oh!
There was an error while loading.Please reload this page.
Fix segfault when calling repr for BaseExceptionGroup.
cc@dr-carlos
BaseExceptionGroup_repr#146096