GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97018)

(cherry picked from commit 8fd2c3b75b)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
This commit is contained in:
Miss Islington (bot) 2022-09-22 10:17:53 -07:00 committed by Pablo Galindo
parent 886fd3938b
commit 154b3cd751
No known key found for this signature in database
GPG key ID: FFE87404168BD847
4 changed files with 79 additions and 3 deletions

View file

@ -7115,11 +7115,14 @@ _PyEval_GetFrame(void)
PyFrameObject *
PyEval_GetFrame(void)
{
PyThreadState *tstate = _PyThreadState_GET();
if (tstate->cframe->current_frame == NULL) {
_PyInterpreterFrame *frame = _PyEval_GetFrame();
while (frame && _PyFrame_IsIncomplete(frame)) {
frame = frame->previous;
}
if (frame == NULL) {
return NULL;
}
PyFrameObject *f = _PyFrame_GetFrameObject(tstate->cframe->current_frame);
PyFrameObject *f = _PyFrame_GetFrameObject(frame);
if (f == NULL) {
PyErr_Clear();
}