diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-10-05 05:46:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 05:46:34 (GMT) |
commit | 015b49ac05eddcb7f653ed2c80daba24ff396fd9 (patch) | |
tree | 7930e4c30215dca26464997ef4d7877c603967d5 /Python | |
parent | 8c517d88fb5ac6f1145128804fe10d5ef9d12b07 (diff) | |
download | cpython-015b49ac05eddcb7f653ed2c80daba24ff396fd9.zip cpython-015b49ac05eddcb7f653ed2c80daba24ff396fd9.tar.gz cpython-015b49ac05eddcb7f653ed2c80daba24ff396fd9.tar.bz2 |
[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 <brandtbucher@microsoft.com>
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 45072da..9f58c20 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)) { |