diff options
author | Vladimir Matveev <vladima@fb.com> | 2020-11-10 20:09:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 20:09:55 (GMT) |
commit | 1e996c3a3b51e9c6f1f4cea8a6dbcf3bcb865060 (patch) | |
tree | 3f3ffd5d90532c6f4b1ec013919e3677d63dd21c /Include | |
parent | e59b2deffde61e5641cabd65034fa11b4db898ba (diff) | |
download | cpython-1e996c3a3b51e9c6f1f4cea8a6dbcf3bcb865060.zip cpython-1e996c3a3b51e9c6f1f4cea8a6dbcf3bcb865060.tar.gz cpython-1e996c3a3b51e9c6f1f4cea8a6dbcf3bcb865060.tar.bz2 |
bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values (#22780)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/abstract.h | 5 | ||||
-rw-r--r-- | Include/cpython/object.h | 3 | ||||
-rw-r--r-- | Include/object.h | 14 | ||||
-rw-r--r-- | Include/typeslots.h | 4 |
4 files changed, 21 insertions, 5 deletions
diff --git a/Include/abstract.h b/Include/abstract.h index 28e576b..0bd1ca9 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -339,11 +339,6 @@ PyAPI_FUNC(int) PyIter_Check(PyObject *); PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 -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: diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 0db53c3..ec6a364 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -167,10 +167,13 @@ typedef struct { objobjargproc mp_ass_subscript; } PyMappingMethods; +typedef PySendResult (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result); + typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; + sendfunc am_send; } PyAsyncMethods; typedef struct { diff --git a/Include/object.h b/Include/object.h index eab3228..dd1b217 100644 --- a/Include/object.h +++ b/Include/object.h @@ -356,6 +356,11 @@ given type object has a specified feature. /* Type is abstract and cannot be instantiated */ #define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +/* Type has am_send entry in tp_as_async slot */ +#define Py_TPFLAGS_HAVE_AM_SEND (1UL << 21) +#endif + /* These flags are used to determine if a type is a subclass. */ #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) #define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) @@ -582,6 +587,15 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ #define Py_GT 4 #define Py_GE 5 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +/* Result of calling PyIter_Send */ +typedef enum { + PYGEN_RETURN = 0, + PYGEN_ERROR = -1, + PYGEN_NEXT = 1, +} PySendResult; +#endif + /* * Macro for implementing rich comparisons * diff --git a/Include/typeslots.h b/Include/typeslots.h index 64f6fff..5800d01 100644 --- a/Include/typeslots.h +++ b/Include/typeslots.h @@ -88,3 +88,7 @@ /* New in 3.5 */ #define Py_tp_finalize 80 #endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +/* New in 3.10 */ +#define Py_am_send 81 +#endif |