Skip to content

Commit e9fec3d

Browse files
committed
Use the exceptions tuple for all non-lists in ExceptionGroup repr
1 parent 79dd615 commit e9fec3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Objects/exceptions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,11 +1070,13 @@ BaseExceptionGroup_repr(PyObject *op)
10701070
assert(self->msg);
10711071
assert(self->excs);
10721072

1073+
/* Use the actual exceptions tuple for accuracy, but make it look like the
1074+
* original exception sequence, if possible, for backwards compatibility. */
10731075
PyObject* excs_orig = PyTuple_GET_ITEM(self->args, 1);
10741076
if (PyList_Check(excs_orig)) {
10751077
excs_orig = PySequence_List(self->excs);
10761078
} else {
1077-
Py_INCREF(excs_orig);
1079+
excs_orig = Py_NewRef(self->excs);
10781080
}
10791081

10801082
const char *name = _PyType_Name(Py_TYPE(self));

0 commit comments

Comments
 (0)