diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-10-05 00:30:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 00:30:03 (GMT) |
commit | 0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85 (patch) | |
tree | ba515469a236a046b09329fbcd49c33eb65c267d /Python | |
parent | c3648f4e4a12ec6efe65684facfcd08996e550ca (diff) | |
download | cpython-0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85.zip cpython-0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85.tar.gz cpython-0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85.tar.bz2 |
GH-97779: Ensure that *all* frame objects are backed by "complete" frames (GH-97845)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/frame.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/frame.c b/Python/frame.c index 05a8cff..96566de 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -70,6 +70,13 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame) frame = (_PyInterpreterFrame *)f->_f_frame_data; f->f_frame = frame; frame->owner = FRAME_OWNED_BY_FRAME_OBJECT; + if (_PyFrame_IsIncomplete(frame)) { + // This may be a newly-created generator or coroutine frame. Since it's + // dead anyways, just pretend that the first RESUME ran: + PyCodeObject *code = frame->f_code; + frame->prev_instr = _PyCode_CODE(code) + code->_co_firsttraceable; + } + assert(!_PyFrame_IsIncomplete(frame)); assert(f->f_back == NULL); _PyInterpreterFrame *prev = frame->previous; while (prev && _PyFrame_IsIncomplete(prev)) { |