mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-41756: Add PyIter_Send function (#22443)
This commit is contained in:
parent
9975cc5008
commit
037245c5ac
12 changed files with 78 additions and 42 deletions
|
@ -16,7 +16,6 @@ _Py_IDENTIFIER(add_done_callback);
|
|||
_Py_IDENTIFIER(call_soon);
|
||||
_Py_IDENTIFIER(cancel);
|
||||
_Py_IDENTIFIER(get_event_loop);
|
||||
_Py_IDENTIFIER(send);
|
||||
_Py_IDENTIFIER(throw);
|
||||
|
||||
|
||||
|
@ -2695,13 +2694,7 @@ task_step_impl(TaskObj *task, PyObject *exc)
|
|||
|
||||
int gen_status = PYGEN_ERROR;
|
||||
if (exc == NULL) {
|
||||
if (PyGen_CheckExact(coro) || PyCoro_CheckExact(coro)) {
|
||||
gen_status = PyGen_Send((PyGenObject*)coro, Py_None, &result);
|
||||
}
|
||||
else {
|
||||
result = _PyObject_CallMethodIdOneArg(coro, &PyId_send, Py_None);
|
||||
gen_status = gen_status_from_result(&result);
|
||||
}
|
||||
gen_status = PyIter_Send(coro, Py_None, &result);
|
||||
}
|
||||
else {
|
||||
result = _PyObject_CallMethodIdOneArg(coro, &PyId_throw, exc);
|
||||
|
|
|
@ -5028,6 +5028,7 @@ dict_get_version(PyObject *self, PyObject *args)
|
|||
static PyObject *
|
||||
raise_SIGINT_then_send_None(PyObject *self, PyObject *args)
|
||||
{
|
||||
_Py_IDENTIFIER(send);
|
||||
PyGenObject *gen;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", &PyGen_Type, &gen))
|
||||
|
@ -5044,7 +5045,7 @@ raise_SIGINT_then_send_None(PyObject *self, PyObject *args)
|
|||
because we check for signals before every bytecode operation.
|
||||
*/
|
||||
raise(SIGINT);
|
||||
return _PyGen_Send(gen, Py_None);
|
||||
return _PyObject_CallMethodIdOneArg((PyObject *)gen, &PyId_send, Py_None);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue