Skip to content

Commit

Permalink
Generate short wrappers for "__await__()" special method to adapt its…
Browse files Browse the repository at this point in the history
… signature for the PyCFunction entry in PyMethodDef.

See #2363.
  • Loading branch information
scoder committed Jun 17, 2018
1 parent 9e18314 commit c1706e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Cython/Utility/Coroutine.c
Expand Up @@ -1458,6 +1458,12 @@ static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
return (PyObject*)await;
}

#if PY_VERSION_HEX < 0x030500B1
static PyObject *__Pyx_Coroutine_await_method(PyObject *coroutine, CYTHON_UNUSED PyObject *arg) {
return __Pyx__Coroutine_await(coroutine);
}
#endif

static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) {
if (unlikely(!coroutine || !__Pyx_Coroutine_Check(coroutine))) {
PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine");
Expand Down Expand Up @@ -1495,7 +1501,7 @@ static PyMethodDef __pyx_Coroutine_methods[] = {
{"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
(char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
#if PY_VERSION_HEX < 0x030500B1
{"__await__", (PyCFunction) __Pyx_Coroutine_await, METH_NOARGS,
{"__await__", (PyCFunction) __Pyx_Coroutine_await_method, METH_NOARGS,
(char*) PyDoc_STR("__await__() -> return an iterator to be used in await expression.")},
#endif
{0, 0, 0, 0}
Expand Down

0 comments on commit c1706e6

Please sign in to comment.