Skip to content
Prev Previous commit
Next Next commit
Avoid creating frame objects for incomplete frames vai f_back.
  • Loading branch information
markshannon committed Jun 28, 2022
commit f56451bc4aea748369d7ba28bff9a28b6e8e4e66
10 changes: 8 additions & 2 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,14 @@ PyFrame_GetBack(PyFrameObject *frame)
{
assert(frame != NULL);
PyFrameObject *back = frame->f_back;
if (back == NULL && frame->f_frame->previous != NULL) {
back = _PyFrame_GetFrameObject(frame->f_frame->previous);
if (back == NULL) {
_PyInterpreterFrame *prev = frame->f_frame->previous;
while (prev && _PyFrame_IsIncomplete(prev)) {
prev = prev->previous;
}
if (prev) {
back = _PyFrame_GetFrameObject(prev);
}
}
Py_XINCREF(back);
return back;
Expand Down