mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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.
This commit is contained in:
parent
489c36920e
commit
b37181e692
10 changed files with 2680 additions and 2612 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue