summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-08-11 13:06:32 (GMT)
committerGitHub <noreply@github.com>2022-08-11 13:06:32 (GMT)
commit1b46d118e6e72daa64b98cafddb406c68b419efa (patch)
tree2c165173112ccf7104d5bc075e2a10988185a5c1 /Python/pystate.c
parent23a757f44fbe29924da8bec7f3682f99a2c0fee5 (diff)
downloadcpython-1b46d118e6e72daa64b98cafddb406c68b419efa.zip
cpython-1b46d118e6e72daa64b98cafddb406c68b419efa.tar.gz
cpython-1b46d118e6e72daa64b98cafddb406c68b419efa.tar.bz2
GH-95818: Skip incomplete frames in `PyThreadState_GetFrame` (GH-95886)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 11cc122..bcdb825 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1255,10 +1255,14 @@ PyFrameObject*
PyThreadState_GetFrame(PyThreadState *tstate)
{
assert(tstate != NULL);
- if (tstate->cframe->current_frame == NULL) {
+ _PyInterpreterFrame *f = tstate->cframe->current_frame;
+ while (f && _PyFrame_IsIncomplete(f)) {
+ f = f->previous;
+ }
+ if (f == NULL) {
return NULL;
}
- PyFrameObject *frame = _PyFrame_GetFrameObject(tstate->cframe->current_frame);
+ PyFrameObject *frame = _PyFrame_GetFrameObject(f);
if (frame == NULL) {
PyErr_Clear();
}