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

This commit is contained in:
Brandt Bucher 2022-09-22 09:16:52 -07:00 committed by GitHub
parent ec403536f1
commit 8fd2c3b75b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 3 deletions

View file

@ -6520,11 +6520,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();
}