diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-01-09 20:20:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 20:20:04 (GMT) |
commit | 61762b93871419b34f02d83cee5ca0d94d4a2903 (patch) | |
tree | 286b9aff961b5435e2d34894857a603ae86aa5c6 /Objects/genobject.c | |
parent | 2e80c2a976c13dcb69a654b386164dca362295a3 (diff) | |
download | cpython-61762b93871419b34f02d83cee5ca0d94d4a2903.zip cpython-61762b93871419b34f02d83cee5ca0d94d4a2903.tar.gz cpython-61762b93871419b34f02d83cee5ca0d94d4a2903.tar.bz2 |
GH-100126: Skip incomplete frames in more places (GH-100613)
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 6f4046e..2adb1e4 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -903,8 +903,11 @@ _Py_MakeCoro(PyFunctionObject *func) if (origin_depth == 0) { ((PyCoroObject *)coro)->cr_origin_or_finalizer = NULL; } else { - assert(_PyEval_GetFrame()); - PyObject *cr_origin = compute_cr_origin(origin_depth, _PyEval_GetFrame()->previous); + _PyInterpreterFrame *frame = tstate->cframe->current_frame; + assert(frame); + assert(_PyFrame_IsIncomplete(frame)); + frame = _PyFrame_GetFirstComplete(frame->previous); + PyObject *cr_origin = compute_cr_origin(origin_depth, frame); ((PyCoroObject *)coro)->cr_origin_or_finalizer = cr_origin; if (!cr_origin) { Py_DECREF(coro); @@ -1286,7 +1289,7 @@ compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame) /* First count how many frames we have */ int frame_count = 0; for (; frame && frame_count < origin_depth; ++frame_count) { - frame = frame->previous; + frame = _PyFrame_GetFirstComplete(frame->previous); } /* Now collect them */ @@ -1305,7 +1308,7 @@ compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame) return NULL; } PyTuple_SET_ITEM(cr_origin, i, frameinfo); - frame = frame->previous; + frame = _PyFrame_GetFirstComplete(frame->previous); } return cr_origin; |