summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2023-01-09 20:20:04 (GMT)
committerGitHub <noreply@github.com>2023-01-09 20:20:04 (GMT)
commit61762b93871419b34f02d83cee5ca0d94d4a2903 (patch)
tree286b9aff961b5435e2d34894857a603ae86aa5c6 /Include
parent2e80c2a976c13dcb69a654b386164dca362295a3 (diff)
downloadcpython-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.h15
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 *