summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-04 18:43:12 (GMT)
committerGitHub <noreply@github.com>2022-07-04 18:43:12 (GMT)
commit68f5fa668343341b79ce1e23f1d9e773b98fd312 (patch)
treebc9b4ab897d1addc94ebf52c643e720fb75944d7 /Python/sysmodule.c
parent8fe0b1d8fa3451e923d7632263be6145a0734468 (diff)
downloadcpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.zip
cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.tar.gz
cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.tar.bz2
[3.11] GH-94262: Don't create frame objects for frames that aren't yet complete. (GH-94371) (#94482)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 7698641..261ebb9 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1784,9 +1784,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,