gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Objects/) (#102218)

This commit is contained in:
Irit Katriel 2023-03-08 17:03:18 +00:00 committed by GitHub
parent b097925858
commit 11a2c6ce51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 106 deletions

View file

@ -4397,10 +4397,9 @@ static void
type_dealloc_common(PyTypeObject *type)
{
if (type->tp_bases != NULL) {
PyObject *tp, *val, *tb;
PyErr_Fetch(&tp, &val, &tb);
PyObject *exc = PyErr_GetRaisedException();
remove_all_subclasses(type, type->tp_bases);
PyErr_Restore(tp, val, tb);
PyErr_SetRaisedException(exc);
}
}
@ -8445,10 +8444,9 @@ slot_tp_finalize(PyObject *self)
{
int unbound;
PyObject *del, *res;
PyObject *error_type, *error_value, *error_traceback;
/* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback);
PyObject *exc = PyErr_GetRaisedException();
/* Execute __del__ method, if any. */
del = lookup_maybe_method(self, &_Py_ID(__del__), &unbound);
@ -8462,7 +8460,7 @@ slot_tp_finalize(PyObject *self)
}
/* Restore the saved exception. */
PyErr_Restore(error_type, error_value, error_traceback);
PyErr_SetRaisedException(exc);
}
static PyObject *