mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values (#22780)
This commit is contained in:
parent
e59b2deffd
commit
1e996c3a3b
13 changed files with 146 additions and 49 deletions
|
@ -2669,6 +2669,32 @@ PyIter_Next(PyObject *iter)
|
|||
return result;
|
||||
}
|
||||
|
||||
PySendResult
|
||||
PyIter_Send(PyObject *iter, PyObject *arg, PyObject **result)
|
||||
{
|
||||
_Py_IDENTIFIER(send);
|
||||
assert(arg != NULL);
|
||||
assert(result != NULL);
|
||||
if (PyType_HasFeature(Py_TYPE(iter), Py_TPFLAGS_HAVE_AM_SEND)) {
|
||||
assert (Py_TYPE(iter)->tp_as_async != NULL);
|
||||
assert (Py_TYPE(iter)->tp_as_async->am_send != NULL);
|
||||
return Py_TYPE(iter)->tp_as_async->am_send(iter, arg, result);
|
||||
}
|
||||
if (arg == Py_None && PyIter_Check(iter)) {
|
||||
*result = Py_TYPE(iter)->tp_iternext(iter);
|
||||
}
|
||||
else {
|
||||
*result = _PyObject_CallMethodIdOneArg(iter, &PyId_send, arg);
|
||||
}
|
||||
if (*result != NULL) {
|
||||
return PYGEN_NEXT;
|
||||
}
|
||||
if (_PyGen_FetchStopIterationValue(result) == 0) {
|
||||
return PYGEN_RETURN;
|
||||
}
|
||||
return PYGEN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flatten a sequence of bytes() objects into a C array of
|
||||
* NULL terminated string pointers with a NULL char* terminating the array.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue