Skip to content

Commit 3064f2d

Browse files
committed
Modules/_testcapi/heaptype.c
1 parent 15e3964 commit 3064f2d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Modules/_testcapi/heaptype.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,16 +623,15 @@ heapctypesubclasswithfinalizer_init(PyObject *self, PyObject *args, PyObject *kw
623623
static void
624624
heapctypesubclasswithfinalizer_finalize(PyObject *self)
625625
{
626-
PyObject *error_type, *error_value, *error_traceback, *m;
627626
PyObject *oldtype = NULL, *newtype = NULL, *refcnt = NULL;
628627

629628
/* Save the current exception, if any. */
630-
PyErr_Fetch(&error_type, &error_value, &error_traceback);
629+
PyObject *exc = PyErr_GetRaisedException();
631630

632631
if (_testcapimodule == NULL) {
633632
goto cleanup_finalize;
634633
}
635-
m = PyState_FindModule(_testcapimodule);
634+
PyObject *m = PyState_FindModule(_testcapimodule);
636635
if (m == NULL) {
637636
goto cleanup_finalize;
638637
}
@@ -667,7 +666,7 @@ heapctypesubclasswithfinalizer_finalize(PyObject *self)
667666
Py_XDECREF(refcnt);
668667

669668
/* Restore the saved exception. */
670-
PyErr_Restore(error_type, error_value, error_traceback);
669+
PyErr_SetRaisedException(exc);
671670
}
672671

673672
static PyType_Slot HeapCTypeSubclassWithFinalizer_slots[] = {

0 commit comments

Comments
 (0)