diff options
author | Vladimir Matveev <vladima@fb.com> | 2020-10-10 00:15:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-10 00:15:15 (GMT) |
commit | 037245c5ac46c3436f617a1f5d965929754be239 (patch) | |
tree | ce2a797b165e846d59e53ba5d530413cb573a8aa /Include | |
parent | 9975cc5008c795e069ce11e2dbed2110cc12e74e (diff) | |
download | cpython-037245c5ac46c3436f617a1f5d965929754be239.zip cpython-037245c5ac46c3436f617a1f5d965929754be239.tar.gz cpython-037245c5ac46c3436f617a1f5d965929754be239.tar.bz2 |
bpo-41756: Add PyIter_Send function (#22443)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/abstract.h | 16 | ||||
-rw-r--r-- | Include/genobject.h | 8 |
2 files changed, 17 insertions, 7 deletions
diff --git a/Include/abstract.h b/Include/abstract.h index a23b7dc..716cd4b 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -338,6 +338,22 @@ PyAPI_FUNC(int) PyIter_Check(PyObject *); NULL with an exception means an error occurred. */ PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); +typedef enum { + PYGEN_RETURN = 0, + PYGEN_ERROR = -1, + PYGEN_NEXT = 1, +} PySendResult; + +/* Takes generator, coroutine or iterator object and sends the value into it. + 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) PyIter_Send(PyObject *, PyObject *, PyObject **); + /* === Number Protocol ================================================== */ diff --git a/Include/genobject.h b/Include/genobject.h index 7488054..e719b25 100644 --- a/Include/genobject.h +++ b/Include/genobject.h @@ -9,6 +9,7 @@ extern "C" { #endif #include "pystate.h" /* _PyErr_StackItem */ +#include "abstract.h" /* PySendResult */ /* _PyGenObject_HEAD defines the initial segment of generator and coroutine objects. */ @@ -41,16 +42,9 @@ PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *, PyObject *name, PyObject *qualname); PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *); PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); -PyAPI_FUNC(PyObject *) _PyGen_Send(PyGenObject *, PyObject *); PyObject *_PyGen_yf(PyGenObject *); PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self); -typedef enum { - PYGEN_RETURN = 0, - PYGEN_ERROR = -1, - PYGEN_NEXT = 1, -} PySendResult; - /* Sends the value into the generator or the coroutine. Returns: - PYGEN_RETURN (0) if generator has returned. 'result' parameter is filled with return value |