]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Delete PyGen_Send (#22663)
authorVladimir Matveev <vladima@fb.com>
Mon, 12 Oct 2020 19:10:42 +0000 (12:10 -0700)
committerGitHub <noreply@github.com>
Mon, 12 Oct 2020 19:10:42 +0000 (12:10 -0700)
Doc/c-api/gen.rst
Doc/data/refcounts.dat
Doc/whatsnew/3.10.rst
Include/genobject.h
Misc/NEWS.d/3.10.0a1.rst
Objects/abstract.c
Objects/genobject.c

index 600f53486f79d5b187289931222691475b0ba325..74410927bfde107c8a8c1e4a5ee1f0a4a9302a0a 100644 (file)
@@ -42,13 +42,3 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.
    with ``__name__`` and ``__qualname__`` set to *name* and *qualname*.
    A reference to *frame* is stolen by this function.  The *frame* argument
    must not be ``NULL``.
-
-.. c:function:: PySendResult PyGen_Send(PyGenObject *gen, PyObject *arg, PyObject **presult)
-
-   Sends the *arg* value into the generator *gen*. Coroutine objects
-   are also allowed to be as the *gen* argument but they need to be
-   explicitly casted to PyGenObject*. Returns:
-
-   - ``PYGEN_RETURN`` if generator returns. Return value is returned via *presult*.
-   - ``PYGEN_NEXT`` if generator yields. Yielded value is returned via *presult*.
-   - ``PYGEN_ERROR`` if generator has raised and exception. *presult* is set to ``NULL``.
index 87ce5d03d0064437c81422edb9d78ec6bfec9330..d01e99ca5e3191bfd876eeecc38fb345b2631f67 100644 (file)
@@ -959,11 +959,6 @@ PyGen_NewWithQualName:PyFrameObject*:frame:0:
 PyGen_NewWithQualName:PyObject*:name:0:
 PyGen_NewWithQualName:PyObject*:qualname:0:
 
-PyGen_Send:int:::
-PyGen_Send:PyGenObject*:gen:0:
-PyGen_Send:PyObject*:arg:0:
-PyGen_Send:PyObject**:presult:+1:
-
 PyCoro_CheckExact:int:::
 PyCoro_CheckExact:PyObject*:ob:0:
 
index 1c50978a8b7501d0b086c18b600cea55573bc082..c8ddcd2d24296e58f84d2feb62ac594ab5859039 100644 (file)
@@ -314,7 +314,7 @@ New Features
   search function.
   (Contributed by Hai Shi in :issue:`41842`.)
 
-* The :c:func:`PyIter_Send` and :c:func:`PyGen_Send` functions were added to allow
+* The :c:func:`PyIter_Send` function was added to allow
   sending value into iterator without raising ``StopIteration`` exception.
   (Contributed by Vladimir Matveev in :issue:`41756`.)
 
index e719b25a8007294b999def4c2d3f0959433dc163..e965334a0140c8097351c391f5314d58b7e799d5 100644 (file)
@@ -45,15 +45,6 @@ PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
 PyObject *_PyGen_yf(PyGenObject *);
 PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
 
-/* Sends the value into the generator or the coroutine. Returns:
-   - PYGEN_RETURN (0) if generator has returned.
-     'result' parameter is filled with return value
-   - PYGEN_ERROR (-1) if exception was raised.
-     'result' parameter is NULL
-   - PYGEN_NEXT (1) if generator has yielded.
-     'result' parameter is filled with yielded value. */
-PyAPI_FUNC(PySendResult) PyGen_Send(PyGenObject *, PyObject *, PyObject **);
-
 #ifndef Py_LIMITED_API
 typedef struct {
     _PyGenObject_HEAD(cr)
index 725dfd16b180a77bad4a1e79d94bbc74dcf2d763..044bd20594cc379cacb6c56bdbf1ca6c511578fd 100644 (file)
@@ -133,16 +133,6 @@ Port the :mod:`_lsprof` extension module to multi-phase initialization
 
 ..
 
-.. bpo: 41756
-.. date: 2020-09-12-12-55-45
-.. nonce: 1h0tbV
-.. section: Core and Builtins
-
-Add PyGen_Send function to allow sending value into generator/coroutine
-without raising StopIteration exception to signal return
-
-..
-
 .. bpo: 1635741
 .. date: 2020-09-08-21-58-47
 .. nonce: vdjSLH
index 502a2d64e25e112814245ea81571e0e1cf54731a..562549876beed82399210d3dd9f7598dd7df6e71 100644 (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.
index eb134ebf4bc8785173365d1728e8fa64b92a41f7..c1b26e9da33bea467d9563d3c29c06ad8b4c3bbc 100644 (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);
+
+    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 *