diff options
author | Vladimir Matveev <vladima@fb.com> | 2020-10-09 17:15:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 17:15:15 -0700 |
commit | 037245c5ac46c3436f617a1f5d965929754be239 (patch) | |
tree | ce2a797b165e846d59e53ba5d530413cb573a8aa /Python/ceval.c | |
parent | 9975cc5008c795e069ce11e2dbed2110cc12e74e (diff) | |
download | cpython-git-037245c5ac46c3436f617a1f5d965929754be239.tar.gz |
bpo-41756: Add PyIter_Send function (#22443)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 500c588e3c..762de577e6 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2210,24 +2210,17 @@ main_loop: case TARGET(YIELD_FROM): { PyObject *v = POP(); PyObject *receiver = TOP(); - int is_gen_or_coro = PyGen_CheckExact(receiver) || PyCoro_CheckExact(receiver); - int gen_status; - if (tstate->c_tracefunc == NULL && is_gen_or_coro) { - gen_status = PyGen_Send((PyGenObject *)receiver, v, &retval); + PySendResult gen_status; + if (tstate->c_tracefunc == NULL) { + gen_status = PyIter_Send(receiver, v, &retval); } else { - if (is_gen_or_coro) { - retval = _PyGen_Send((PyGenObject *)receiver, v); + _Py_IDENTIFIER(send); + if (v == Py_None && PyIter_Check(receiver)) { + retval = Py_TYPE(receiver)->tp_iternext(receiver); } else { - _Py_IDENTIFIER(send); - if (v == Py_None) { - retval = Py_TYPE(receiver)->tp_iternext(receiver); - } - else { - retval = _PyObject_CallMethodIdOneArg(receiver, &PyId_send, v); - } + retval = _PyObject_CallMethodIdOneArg(receiver, &PyId_send, v); } - if (retval == NULL) { if (tstate->c_tracefunc != NULL && _PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) |