From 015b49ac05eddcb7f653ed2c80daba24ff396fd9 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:46:34 -0700 Subject: [3.11] GH-97779: Ensure that *all* frame objects are backed by "complete" frames (GH-97886) (cherry picked from commit 0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85) Co-authored-by: Brandt Bucher --- Python/frame.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Python') diff --git a/Python/frame.c b/Python/frame.c index 45072da0426..9f58c20d4fa 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -68,6 +68,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)) { -- cgit v1.3.1