mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Don't raise an exception on normal return from generator. (GH-19473)
This commit is contained in:
parent
6e23a9c82b
commit
50a48dad55
2 changed files with 3 additions and 1 deletions
|
@ -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)) {
|
if (PyAsyncGen_CheckExact(gen)) {
|
||||||
PyErr_SetNone(PyExc_StopAsyncIteration);
|
PyErr_SetNone(PyExc_StopAsyncIteration);
|
||||||
}
|
}
|
||||||
else {
|
else if (arg) {
|
||||||
|
/* Set exception if not called by gen_iternext() */
|
||||||
PyErr_SetNone(PyExc_StopIteration);
|
PyErr_SetNone(PyExc_StopIteration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue