Delete PyGen_Send (#22663)

This commit is contained in:
Vladimir Matveev 2020-10-12 12:10:42 -07:00 committed by GitHub
parent abe244c458
commit 24a54c0bd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 64 deletions

View file

@ -2669,31 +2669,6 @@ PyIter_Next(PyObject *iter)
return result;
}
PySendResult
PyIter_Send(PyObject *iter, PyObject *arg, PyObject **result)
{
_Py_IDENTIFIER(send);
assert(result != NULL);
if (PyGen_CheckExact(iter) || PyCoro_CheckExact(iter)) {
return PyGen_Send((PyGenObject *)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.

View file

@ -269,13 +269,29 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
}
PySendResult
PyGen_Send(PyGenObject *gen, PyObject *arg, PyObject **result)
PyIter_Send(PyObject *iter, PyObject *arg, PyObject **result)
{
assert(PyGen_CheckExact(gen) || PyCoro_CheckExact(gen));
assert(result != NULL);
_Py_IDENTIFIER(send);
assert(arg != NULL);
assert(result != NULL);
return gen_send_ex2(gen, arg, result, 0, 0);
if (PyGen_CheckExact(iter) || PyCoro_CheckExact(iter)) {
return gen_send_ex2((PyGenObject *)iter, arg, result, 0, 0);
}
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;
}
static PyObject *