Commit 5e7c718a authored by Stefan Behnel's avatar Stefan Behnel

guard the usage of the new PEP 492 async type slots by an explicit feature macro

parent 6931f234
...@@ -118,7 +118,7 @@ static CYTHON_INLINE PyObject* __Pyx_Coroutine_AIter_Yield_From(__pyx_CoroutineO ...@@ -118,7 +118,7 @@ static CYTHON_INLINE PyObject* __Pyx_Coroutine_AIter_Yield_From(__pyx_CoroutineO
//@requires: CoroutineYieldFrom //@requires: CoroutineYieldFrom
static CYTHON_INLINE PyObject* __Pyx_Coroutine_AIter_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) { static CYTHON_INLINE PyObject* __Pyx_Coroutine_AIter_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) {
#if PY_MAJOR_VERSION >= 3 #if CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(source); __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(source);
if (likely(am && am->am_anext)) { if (likely(am && am->am_anext)) {
// Starting with CPython 3.5.2, __aiter__ should return // Starting with CPython 3.5.2, __aiter__ should return
...@@ -180,7 +180,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) { ...@@ -180,7 +180,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
// adapted from genobject.c in Py3.5 // adapted from genobject.c in Py3.5
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) { static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
PyObject *res; PyObject *res;
#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj); __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
if (likely(am && am->am_await)) { if (likely(am && am->am_await)) {
res = (*am->am_await)(obj); res = (*am->am_await)(obj);
...@@ -257,7 +257,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro ...@@ -257,7 +257,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro
//@requires: ObjectHandling.c::PyObjectCallMethod0 //@requires: ObjectHandling.c::PyObjectCallMethod0
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) { static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
#if PY_MAJOR_VERSION >= 3 #if CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj); __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
if (likely(am && am->am_aiter)) { if (likely(am && am->am_aiter)) {
return (*am->am_aiter)(obj); return (*am->am_aiter)(obj);
...@@ -283,7 +283,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) { ...@@ -283,7 +283,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
} }
static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) { static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
#if PY_MAJOR_VERSION >= 3 #if CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj); __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
if (likely(am && am->am_anext)) { if (likely(am && am->am_anext)) {
return (*am->am_anext)(obj); return (*am->am_anext)(obj);
...@@ -1280,7 +1280,7 @@ static PyGetSetDef __pyx_Coroutine_getsets[] = { ...@@ -1280,7 +1280,7 @@ static PyGetSetDef __pyx_Coroutine_getsets[] = {
{0, 0, 0, 0, 0} {0, 0, 0, 0, 0}
}; };
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY #if CYTHON_USE_ASYNC_SLOTS
static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = { static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = {
__Pyx_Coroutine_await, /*am_await*/ __Pyx_Coroutine_await, /*am_await*/
0, /*am_aiter*/ 0, /*am_aiter*/
...@@ -1297,8 +1297,8 @@ static PyTypeObject __pyx_CoroutineType_type = { ...@@ -1297,8 +1297,8 @@ static PyTypeObject __pyx_CoroutineType_type = {
0, /*tp_print*/ 0, /*tp_print*/
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY #if CYTHON_USE_ASYNC_SLOTS
&__pyx_Coroutine_as_async, /*tp_as_async (tp_reserved)*/ &__pyx_Coroutine_as_async, /*tp_as_async (tp_reserved) - Py3 only! */
#else #else
0, /*tp_reserved*/ 0, /*tp_reserved*/
#endif #endif
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_CPYTHON 0
#undef CYTHON_USE_TYPE_SLOTS #undef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 0 #define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS #undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0 #define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS #undef CYTHON_USE_UNICODE_INTERNALS
...@@ -55,6 +57,12 @@ ...@@ -55,6 +57,12 @@
#ifndef CYTHON_USE_TYPE_SLOTS #ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1 #define CYTHON_USE_TYPE_SLOTS 1
#endif #endif
#if PY_MAJOR_VERSION < 3
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#ifndef CYTHON_USE_PYLIST_INTERNALS #ifndef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 1 #define CYTHON_USE_PYLIST_INTERNALS 1
#endif #endif
...@@ -253,18 +261,20 @@ ...@@ -253,18 +261,20 @@
// backport of PyAsyncMethods from Py3.5 to older Py3.x versions // backport of PyAsyncMethods from Py3.5 to older Py3.x versions
// (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5 // (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5
#if PY_VERSION_HEX >= 0x030500B1 #if CYTHON_USE_ASYNC_SLOTS
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#elif PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
typedef struct { #else
unaryfunc am_await; typedef struct {
unaryfunc am_aiter; unaryfunc am_await;
unaryfunc am_anext; unaryfunc am_aiter;
} __Pyx_PyAsyncMethodsStruct; unaryfunc am_anext;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) } __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#endif
#else #else
#define __Pyx_PyType_AsAsync(obj) NULL #define __Pyx_PyType_AsAsync(obj) NULL
#endif #endif
// restrict // restrict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment