GH-146096: Fix base exception group repr#146141
Conversation
|
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.
Do we need to check that it's a Tuple first?
There was a problem hiding this comment.
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.
Could add an assert just so it reads like it makes sense.
|
I'm not sure that failed test related to change. |
|
Thanks all! |
Fix segfault when calling repr for BaseExceptionGroup.
cc @dr-carlos
BaseExceptionGroup_repr#146096