Commit 498371be authored by Stefan Behnel's avatar Stefan Behnel

fix up async iter helpers in latest Py3.5

parent a8bc839c
...@@ -94,21 +94,18 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) { ...@@ -94,21 +94,18 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
return __Pyx__Coroutine_GetAwaitableIter(o); return __Pyx__Coroutine_GetAwaitableIter(o);
} }
// copied and adapted from genobject.c in Py3.5 // adapted from genobject.c in Py3.5
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o) { static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
PyObject *res; PyObject *res;
#if PY_VERSION_HEX >= 0x030500B1 #if PY_VERSION_HEX >= 0x030500B1
unaryfunc getter = NULL; PyAsyncMethods* am = Py_TYPE(obj)->tp_as_async;
PyTypeObject *ot; if (likely(am && am->am_await)) {
res = (*am->am_await)(obj);
ot = Py_TYPE(o); } else {
if (likely(ot->tp_as_async)) { goto slot_error;
getter = (unaryfunc) ot->tp_as_async->am_await;
} }
if (unlikely(getter)) goto slot_error;
res = (*getter)(o);
#else #else
PyObject *method = __Pyx_PyObject_GetAttrStr(o, PYIDENT("__await__")); PyObject *method = __Pyx_PyObject_GetAttrStr(obj, PYIDENT("__await__"));
if (unlikely(!method)) goto slot_error; if (unlikely(!method)) goto slot_error;
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyMethod_Check(method))) { if (likely(PyMethod_Check(method))) {
...@@ -149,7 +146,7 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o) { ...@@ -149,7 +146,7 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o) {
slot_error: slot_error:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"object %.100s can't be used in 'await' expression", "object %.100s can't be used in 'await' expression",
Py_TYPE(o)->tp_name); Py_TYPE(obj)->tp_name);
bad: bad:
return NULL; return NULL;
} }
...@@ -985,11 +982,11 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) { ...@@ -985,11 +982,11 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
} }
#if PY_VERSION_HEX >= 0x030500B1 #if PY_VERSION_HEX >= 0x030500B1
static PyAsyncMethods __pyx_Coroutine_as_async { static PyAsyncMethods __pyx_Coroutine_as_async = {
0, /*am_await*/ 0, /*am_await*/
0, /*am_aiter*/ 0, /*am_aiter*/
0, /*am_anext*/ 0, /*am_anext*/
} };
#endif #endif
static PyTypeObject __pyx_CoroutineType_type = { static PyTypeObject __pyx_CoroutineType_type = {
...@@ -1002,7 +999,7 @@ static PyTypeObject __pyx_CoroutineType_type = { ...@@ -1002,7 +999,7 @@ static PyTypeObject __pyx_CoroutineType_type = {
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
#if PY_VERSION_HEX >= 0x030500B1 #if PY_VERSION_HEX >= 0x030500B1
__pyx_Coroutine_as_async, /*tp_as_async*/ &__pyx_Coroutine_as_async, /*tp_as_async*/
#else #else
0, /*tp_reserved resp. tp_compare*/ 0, /*tp_reserved resp. tp_compare*/
#endif #endif
......
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