From 6a646dd1ffa9ccc9130e09fdd2f5b75652c4f121 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 22 Sep 2022 10:17:53 -0700 Subject: GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97018) (cherry picked from commit 8fd2c3b75b90c4ee391894aa5094615bbdb6242f) Co-authored-by: Brandt Bucher --- Python/ceval.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Python') diff --git a/Python/ceval.c b/Python/ceval.c index 07a5461daf3..c5283ace43c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -7116,11 +7116,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(); } -- cgit v1.3.1