GH-94262: Don't create frame objects for frames that aren't yet complete. (GH-94371)

This commit is contained in:
Mark Shannon 2022-07-01 11:08:20 +01:00 committed by GitHub
parent 1df9449db2
commit 544531de23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 87 additions and 13 deletions

View file

@ -1776,9 +1776,17 @@ sys__getframe_impl(PyObject *module, int depth)
return NULL;
}
while (depth > 0 && frame != NULL) {
frame = frame->previous;
--depth;
if (frame != NULL) {
while (depth > 0) {
frame = frame->previous;
if (frame == NULL) {
break;
}
if (_PyFrame_IsIncomplete(frame)) {
continue;
}
--depth;
}
}
if (frame == NULL) {
_PyErr_SetString(tstate, PyExc_ValueError,