diff options
| author | Mark Shannon <mark@hotpy.org> | 2022-11-03 04:38:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-03 11:38:51 +0000 |
| commit | f4adb975061874566766f7a67206cb7b0439bc11 (patch) | |
| tree | 136b2e8b97fd8811cef1d2ff46d31fb61f26183a /Objects | |
| parent | e9ac890c0273aee413aa528cc202c3efa29f1d7a (diff) | |
| download | cpython-git-f4adb975061874566766f7a67206cb7b0439bc11.tar.gz | |
GH-96793: Implement PEP 479 in bytecode. (GH-99006)
* Handle converting StopIteration to RuntimeError in bytecode.
* Add custom instruction for converting StopIteration into RuntimeError.
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/genobject.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index c62fb62315..2e2b36df06 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -246,25 +246,9 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult, } } else { - if (PyErr_ExceptionMatches(PyExc_StopIteration)) { - const char *msg = "generator raised StopIteration"; - if (PyCoro_CheckExact(gen)) { - msg = "coroutine raised StopIteration"; - } - else if (PyAsyncGen_CheckExact(gen)) { - msg = "async generator raised StopIteration"; - } - _PyErr_FormatFromCause(PyExc_RuntimeError, "%s", msg); - } - else if (PyAsyncGen_CheckExact(gen) && - PyErr_ExceptionMatches(PyExc_StopAsyncIteration)) - { - /* code in `gen` raised a StopAsyncIteration error: - raise a RuntimeError. - */ - const char *msg = "async generator raised StopAsyncIteration"; - _PyErr_FormatFromCause(PyExc_RuntimeError, "%s", msg); - } + assert(!PyErr_ExceptionMatches(PyExc_StopIteration)); + assert(!PyAsyncGen_CheckExact(gen) || + !PyErr_ExceptionMatches(PyExc_StopAsyncIteration)); } /* generator can't be rerun, so release the frame */ |
