File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -1086,11 +1086,10 @@ BaseExceptionGroup_repr(PyObject *op)
10861086 PyBaseExceptionGroupObject * self = PyBaseExceptionGroupObject_CAST (op );
10871087 assert (self -> msg );
10881088
1089- PyObject * exceptions_str = Py_XNewRef ( self -> excs_str ) ;
1089+ PyObject * exceptions_str = NULL ;
10901090
1091- /* If the initial exceptions string was not saved in the constructor,
1092- * our call to Py_XNewRef returns NULL and we now format it on-demand. */
1093- if (!exceptions_str ) {
1091+ /* If the initial exceptions string was not saved in the constructor. */
1092+ if (!self -> excs_str ) {
10941093 assert (self -> excs );
10951094
10961095 /* Older versions of this code delegated to BaseException's repr, inserting
@@ -1110,12 +1109,16 @@ BaseExceptionGroup_repr(PyObject *op)
11101109 else {
11111110 exceptions_str = PyObject_Repr (self -> excs );
11121111 }
1113- }
11141112
1115- if (!exceptions_str ) {
1116- goto error ;
1113+ if (!exceptions_str ) {
1114+ goto error ;
1115+ }
1116+ } else {
1117+ exceptions_str = Py_NewRef (self -> excs_str );
11171118 }
11181119
1120+ assert (exceptions_str != NULL );
1121+
11191122 const char * name = _PyType_Name (Py_TYPE (self ));
11201123 PyObject * repr = PyUnicode_FromFormat (
11211124 "%s(%R, %U)" , name ,
You can’t perform that action at this time.
0 commit comments