diff options
author | Mark Shannon <mark@hotpy.org> | 2021-04-06 11:48:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 11:48:59 +0100 |
commit | b37181e69209746adc2119c471599a1ea5faa6c8 (patch) | |
tree | 3605b5e9447fe18ed0c87b745daef1216301583f /Python/ceval.c | |
parent | 489c36920e94bfb4988b6f965bd0aafdfaff0d4f (diff) | |
download | cpython-b37181e69209746adc2119c471599a1ea5faa6c8.tar.gz cpython-b37181e69209746adc2119c471599a1ea5faa6c8.zip |
bpo-43683: Handle generator entry in bytecode (GH-25138)
* Handle check for sending None to starting generator and coroutine into bytecode.
* Document new bytecode and make it fail gracefully if mis-compiled.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index d9a754fb910..eda99392709 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2639,6 +2639,30 @@ main_loop: goto exiting; } + case TARGET(GEN_START): { + PyObject *none = POP(); + Py_DECREF(none); + if (none != Py_None) { + if (oparg > 2) { + _PyErr_SetString(tstate, PyExc_SystemError, + "Illegal kind for GEN_START"); + } + else { + static const char *gen_kind[3] = { + "generator", + "coroutine", + "async generator" + }; + _PyErr_Format(tstate, PyExc_TypeError, + "can't send non-None value to a " + "just-started %s", + gen_kind[oparg]); + } + goto error; + } + DISPATCH(); + } + case TARGET(POP_EXCEPT): { PyObject *type, *value, *traceback; _PyErr_StackItem *exc_info; |