mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (#102193)
This commit is contained in:
parent
85b1fc1fc5
commit
4c87537efb
8 changed files with 42 additions and 72 deletions
|
@ -29,17 +29,14 @@ PyFrameObject *
|
|||
_PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame)
|
||||
{
|
||||
assert(frame->frame_obj == NULL);
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
|
||||
PyFrameObject *f = _PyFrame_New_NoTrack(frame->f_code);
|
||||
if (f == NULL) {
|
||||
Py_XDECREF(error_type);
|
||||
Py_XDECREF(error_value);
|
||||
Py_XDECREF(error_traceback);
|
||||
Py_XDECREF(exc);
|
||||
return NULL;
|
||||
}
|
||||
PyErr_Restore(error_type, error_value, error_traceback);
|
||||
PyErr_SetRaisedException(exc);
|
||||
if (frame->frame_obj) {
|
||||
// GH-97002: How did we get into this horrible situation? Most likely,
|
||||
// allocating f triggered a GC collection, which ran some code that
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue