mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-46009: Do not exhaust generator when send() method raises (GH-29986)
This commit is contained in:
parent
3e0f13b9e4
commit
69806b9516
5 changed files with 30 additions and 21 deletions
|
@ -2714,25 +2714,9 @@ check_eval_breaker:
|
|||
|
||||
TARGET(GEN_START) {
|
||||
PyObject *none = POP();
|
||||
assert(none == Py_None);
|
||||
assert(oparg < 3);
|
||||
Py_DECREF(none);
|
||||
if (!Py_IsNone(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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue