summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-12-08 14:46:32 (GMT)
committerGitHub <noreply@github.com>2021-12-08 14:46:32 (GMT)
commit99c72326d245fb604609a87a51ef1ad0845467b7 (patch)
tree62317e0c33adb14af339a75d924365c2957ba8c3 /Python/ceval.c
parentcca3004f64d49c9e170396ac787712fe03bffb29 (diff)
downloadcpython-99c72326d245fb604609a87a51ef1ad0845467b7.zip
cpython-99c72326d245fb604609a87a51ef1ad0845467b7.tar.gz
cpython-99c72326d245fb604609a87a51ef1ad0845467b7.tar.bz2
[3.10] bpo-46009: Do not exhaust generator when send() method raises (GH-29986). (GH-29988)
* [3.10] bpo-46009: Do not exhaust generator when send() method raises (GH-29986). (cherry picked from commit 69806b9516dbe092381f3ef884c7c64bb9b8414a) Co-authored-by: Mark Shannon <mark@hotpy.org> * Rename variable after cherry-pick. * Add NULL check.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 624baf5..8ad1713 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2649,25 +2649,9 @@ main_loop:
case 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();
}