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 /Include | |
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 'Include')
-rw-r--r-- | Include/internal/pycore_frame.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index 4e2051f..f12b225 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -166,6 +166,21 @@ _PyFrame_IsIncomplete(_PyInterpreterFrame *frame) frame->prev_instr < _PyCode_CODE(frame->f_code) + frame->f_code->_co_firsttraceable; } +static inline _PyInterpreterFrame * +_PyFrame_GetFirstComplete(_PyInterpreterFrame *frame) +{ + while (frame && _PyFrame_IsIncomplete(frame)) { + frame = frame->previous; + } + return frame; +} + +static inline _PyInterpreterFrame * +_PyThreadState_GetFrame(PyThreadState *tstate) +{ + return _PyFrame_GetFirstComplete(tstate->cframe->current_frame); +} + /* For use by _PyFrame_GetFrameObject Do not call directly. */ PyFrameObject * |