mirror of
https://github.com/python/cpython.git
synced 2025-08-08 02:48:55 +00:00
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Objects/) (#102218)
This commit is contained in:
parent
b097925858
commit
11a2c6ce51
8 changed files with 51 additions and 106 deletions
|
@ -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 *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue