diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-08-19 19:33:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 19:33:44 (GMT) |
commit | 5bfb3c372bda1113aea1385d4793f073a1d37155 (patch) | |
tree | a6b30a05ec2e5f59eadff759e47529ee76a6c132 /Objects | |
parent | 2d9f252c0c08bce0e776b38906c3bbb59a3bd2c5 (diff) | |
download | cpython-5bfb3c372bda1113aea1385d4793f073a1d37155.zip cpython-5bfb3c372bda1113aea1385d4793f073a1d37155.tar.gz cpython-5bfb3c372bda1113aea1385d4793f073a1d37155.tar.bz2 |
GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/genobject.c | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 2b45e28..da4afec 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -485,26 +485,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit, } Py_DECREF(yf); if (!ret) { - PyObject *val; - /* Pop subiterator from stack */ - assert(gen->gi_frame_state < FRAME_CLEARED); - ret = _PyFrame_StackPop((_PyInterpreterFrame *)gen->gi_iframe); - assert(ret == yf); - Py_DECREF(ret); - // XXX: Performing this jump ourselves is awkward and problematic. - // See https://github.com/python/cpython/pull/31968. - /* Termination repetition of SEND loop */ - assert(_PyInterpreterFrame_LASTI(frame) >= 0); - /* Backup to SEND */ - assert(_Py_OPCODE(frame->prev_instr[-1]) == SEND); - int jump = _Py_OPARG(frame->prev_instr[-1]); - frame->prev_instr += jump - 1; - if (_PyGen_FetchStopIterationValue(&val) == 0) { - ret = gen_send(gen, val); - Py_DECREF(val); - } else { - ret = gen_send_ex(gen, Py_None, 1, 0); - } + ret = gen_send_ex(gen, Py_None, 1, 0); } return ret; } |