@@ -1246,8 +1246,7 @@ print_chained(struct exception_print_context* ctx, PyObject *value,
1246
1246
const char * message , const char * tag )
1247
1247
{
1248
1248
PyObject * f = ctx -> file ;
1249
-
1250
- if (_Py_EnterRecursiveCall (" in print_chained" ) < 0 ) {
1249
+ if (_Py_EnterRecursiveCall (" in print_chained" ) != 0 ) {
1251
1250
return -1 ;
1252
1251
}
1253
1252
bool need_close = ctx -> need_close ;
@@ -1374,7 +1373,9 @@ print_exception_group(struct exception_print_context *ctx, PyObject *value)
1374
1373
if (ctx -> exception_group_depth == 0 ) {
1375
1374
ctx -> exception_group_depth += 1 ;
1376
1375
}
1377
- print_exception (ctx , value );
1376
+ if (print_exception (ctx , value ) < 0 ) {
1377
+ return -1 ;
1378
+ }
1378
1379
1379
1380
PyObject * excs = ((PyBaseExceptionGroupObject * )value )-> excs ;
1380
1381
assert (excs && PyTuple_Check (excs ));
@@ -1477,22 +1478,30 @@ print_exception_group(struct exception_print_context *ctx, PyObject *value)
1477
1478
static int
1478
1479
print_exception_recursive (struct exception_print_context * ctx , PyObject * value )
1479
1480
{
1481
+ if (_Py_EnterRecursiveCall (" in print_exception_recursive" ) != 0 ) {
1482
+ return -1 ;
1483
+ }
1480
1484
if (ctx -> seen != NULL ) {
1481
1485
/* Exception chaining */
1482
1486
if (print_exception_cause_and_context (ctx , value ) < 0 ) {
1483
- return -1 ;
1487
+ goto error ;
1484
1488
}
1485
1489
}
1486
1490
if (!_PyBaseExceptionGroup_Check (value )) {
1487
1491
if (print_exception (ctx , value ) < 0 ) {
1488
- return -1 ;
1492
+ goto error ;
1489
1493
}
1490
1494
}
1491
1495
else if (print_exception_group (ctx , value ) < 0 ) {
1492
- return -1 ;
1496
+ goto error ;
1493
1497
}
1494
1498
assert (!PyErr_Occurred ());
1499
+
1500
+ _Py_LeaveRecursiveCall ();
1495
1501
return 0 ;
1502
+ error :
1503
+ _Py_LeaveRecursiveCall ();
1504
+ return -1 ;
1496
1505
}
1497
1506
1498
1507
#define PyErr_MAX_GROUP_WIDTH 15
0 commit comments