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 GitHub
parent 773dbb9e3a
commit 6a646dd1ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 3 deletions

View file

@ -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();
}