diff options
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index d334775..6a1ba50 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -166,6 +166,13 @@ gen_iternext(genobject *gen) Py_XDECREF(f->f_back); f->f_back = NULL; + /* If the generator just returned (as opposed to yielding), signal + * that the generator is exhausted. */ + if (result == Py_None && f->f_stacktop == NULL) { + Py_DECREF(result); + result = NULL; + } + return result; } |