summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-22 17:17:53 (GMT)
committerGitHub <noreply@github.com>2022-09-22 17:17:53 (GMT)
commit6a646dd1ffa9ccc9130e09fdd2f5b75652c4f121 (patch)
treeceadad1e80c6efe52ee40af59d622198b9d6a12d /Python/ceval.c
parent773dbb9e3a7dc5d4a8560bc3ffb28c16758f159f (diff)
downloadcpython-6a646dd1ffa9ccc9130e09fdd2f5b75652c4f121.zip
cpython-6a646dd1ffa9ccc9130e09fdd2f5b75652c4f121.tar.gz
cpython-6a646dd1ffa9ccc9130e09fdd2f5b75652c4f121.tar.bz2
GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97018)
(cherry picked from commit 8fd2c3b75b90c4ee391894aa5094615bbdb6242f) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 07a5461..c5283ac 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();
}