@@ -61,9 +61,9 @@ add_new_exception(PyObject *mod, const char *name, PyObject *base)
61
61
static int
62
62
_release_xid_data (_PyCrossInterpreterData * data , int ignoreexc )
63
63
{
64
- PyObject * exctype , * excval , * exctb ;
64
+ PyObject * exc ;
65
65
if (ignoreexc ) {
66
- PyErr_Fetch ( & exctype , & excval , & exctb );
66
+ exc = PyErr_GetRaisedException ( );
67
67
}
68
68
int res = _PyCrossInterpreterData_Release (data );
69
69
if (res < 0 ) {
@@ -84,7 +84,7 @@ _release_xid_data(_PyCrossInterpreterData *data, int ignoreexc)
84
84
}
85
85
}
86
86
if (ignoreexc ) {
87
- PyErr_Restore ( exctype , excval , exctb );
87
+ PyErr_SetRaisedException ( exc );
88
88
}
89
89
return res ;
90
90
}
@@ -294,17 +294,17 @@ _sharedexception_free(_sharedexception *exc)
294
294
}
295
295
296
296
static _sharedexception *
297
- _sharedexception_bind (PyObject * exctype , PyObject * exc , PyObject * tb )
297
+ _sharedexception_bind (PyObject * exc )
298
298
{
299
- assert (exctype != NULL );
299
+ assert (exc != NULL );
300
300
char * failure = NULL ;
301
301
302
302
_sharedexception * err = _sharedexception_new ();
303
303
if (err == NULL ) {
304
304
goto finally ;
305
305
}
306
306
307
- PyObject * name = PyUnicode_FromFormat ("%S" , exctype );
307
+ PyObject * name = PyUnicode_FromFormat ("%S" , Py_TYPE ( exc ) );
308
308
if (name == NULL ) {
309
309
failure = "unable to format exception type name" ;
310
310
goto finally ;
@@ -432,10 +432,7 @@ static int
432
432
_run_script (PyInterpreterState * interp , const char * codestr ,
433
433
_sharedns * shared , _sharedexception * * exc )
434
434
{
435
- PyObject * exctype = NULL ;
436
435
PyObject * excval = NULL ;
437
- PyObject * tb = NULL ;
438
-
439
436
PyObject * main_mod = _PyInterpreterState_GetMainModule (interp );
440
437
if (main_mod == NULL ) {
441
438
goto error ;
@@ -469,12 +466,9 @@ _run_script(PyInterpreterState *interp, const char *codestr,
469
466
return 0 ;
470
467
471
468
error :
472
- PyErr_Fetch (& exctype , & excval , & tb );
473
-
474
- _sharedexception * sharedexc = _sharedexception_bind (exctype , excval , tb );
475
- Py_XDECREF (exctype );
469
+ excval = PyErr_GetRaisedException ();
470
+ _sharedexception * sharedexc = _sharedexception_bind (excval );
476
471
Py_XDECREF (excval );
477
- Py_XDECREF (tb );
478
472
if (sharedexc == NULL ) {
479
473
fprintf (stderr , "RunFailedError: script raised an uncaught exception" );
480
474
PyErr_Clear ();
0 commit comments