aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Matveev <vladima@fb.com>2020-10-12 12:10:42 -0700
committerGitHub <noreply@github.com>2020-10-12 12:10:42 -0700
commit24a54c0bd48d9f6f1a1289ca57afb381bc4b280e (patch)
treeb477987c2774d4cc41a42c85399c22cde0880305 /Objects
parent[doc] Fix typo in the graphlib docs (GH-22661) (diff)
downloadcpython-24a54c0bd48d9f6f1a1289ca57afb381bc4b280e.tar.gz
cpython-24a54c0bd48d9f6f1a1289ca57afb381bc4b280e.tar.bz2
cpython-24a54c0bd48d9f6f1a1289ca57afb381bc4b280e.zip
Delete PyGen_Send (#22663)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c25
-rw-r--r--Objects/genobject.c24
2 files changed, 20 insertions, 29 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 502a2d64e25..562549876be 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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.
diff --git a/Objects/genobject.c b/Objects/genobject.c
index eb134ebf4bc..c1b26e9da33 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -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);
+
+ if (PyGen_CheckExact(iter) || PyCoro_CheckExact(iter)) {
+ return gen_send_ex2((PyGenObject *)iter, arg, result, 0, 0);
+ }
- return gen_send_ex2(gen, 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 *