mirror of https://github.com/python/cpython
Don't raise an exception on normal return from generator. (GH-19473)
This commit is contained in:
parent
6e23a9c82b
commit
50a48dad55
|
@ -0,0 +1 @@
|
|||
Improve performance of generators by not raising internal StopIteration.
|
|
@ -231,7 +231,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)
|
|||
if (PyAsyncGen_CheckExact(gen)) {
|
||||
PyErr_SetNone(PyExc_StopAsyncIteration);
|
||||
}
|
||||
else {
|
||||
else if (arg) {
|
||||
/* Set exception if not called by gen_iternext() */
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue