Skip to content

Commit 8fd66a8

Browse files
committed
Objects/typeobject.c
1 parent fde54d4 commit 8fd66a8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Objects/typeobject.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,10 +4397,9 @@ static void
43974397
type_dealloc_common(PyTypeObject *type)
43984398
{
43994399
if (type->tp_bases != NULL) {
4400-
PyObject *tp, *val, *tb;
4401-
PyErr_Fetch(&tp, &val, &tb);
4400+
PyObject *exc = PyErr_GetRaisedException();
44024401
remove_all_subclasses(type, type->tp_bases);
4403-
PyErr_Restore(tp, val, tb);
4402+
PyErr_SetRaisedException(exc);
44044403
}
44054404
}
44064405

@@ -8445,10 +8444,9 @@ slot_tp_finalize(PyObject *self)
84458444
{
84468445
int unbound;
84478446
PyObject *del, *res;
8448-
PyObject *error_type, *error_value, *error_traceback;
84498447

84508448
/* Save the current exception, if any. */
8451-
PyErr_Fetch(&error_type, &error_value, &error_traceback);
8449+
PyObject *exc = PyErr_GetRaisedException();
84528450

84538451
/* Execute __del__ method, if any. */
84548452
del = lookup_maybe_method(self, &_Py_ID(__del__), &unbound);
@@ -8462,7 +8460,7 @@ slot_tp_finalize(PyObject *self)
84628460
}
84638461

84648462
/* Restore the saved exception. */
8465-
PyErr_Restore(error_type, error_value, error_traceback);
8463+
PyErr_SetRaisedException(exc);
84668464
}
84678465

84688466
static PyObject *

0 commit comments

Comments
 (0)