Commit 4f5e5a30 authored by Stefan Behnel's avatar Stefan Behnel

work around C-API deficiencies in PyPy

parent 659b7413
...@@ -1003,10 +1003,12 @@ static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) { ...@@ -1003,10 +1003,12 @@ static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) {
return self; return self;
} }
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject *__Pyx_CoroutineAwait_no_new(CYTHON_UNUSED PyTypeObject *type, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwargs) { static PyObject *__Pyx_CoroutineAwait_no_new(CYTHON_UNUSED PyTypeObject *type, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwargs) {
PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead"); PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead");
return NULL; return NULL;
} }
#endif
static PyMethodDef __pyx_CoroutineAwait_methods[] = { static PyMethodDef __pyx_CoroutineAwait_methods[] = {
{"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O, {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
...@@ -1056,7 +1058,11 @@ static PyTypeObject __pyx_CoroutineAwaitType_type = { ...@@ -1056,7 +1058,11 @@ static PyTypeObject __pyx_CoroutineAwaitType_type = {
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
0, /*tp_init*/ 0, /*tp_init*/
0, /*tp_alloc*/ 0, /*tp_alloc*/
#if CYTHON_COMPILING_IN_CPYTHON
__Pyx_CoroutineAwait_no_new, /*tp_new*/ __Pyx_CoroutineAwait_no_new, /*tp_new*/
#else
0, /*tp_new*/
#endif
0, /*tp_free*/ 0, /*tp_free*/
0, /*tp_is_gc*/ 0, /*tp_is_gc*/
0, /*tp_bases*/ 0, /*tp_bases*/
...@@ -1075,7 +1081,8 @@ static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) { ...@@ -1075,7 +1081,8 @@ static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON
__pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType); __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType);
#else #else
__pyx_CoroutineAwaitObject *await = __pyx_CoroutineAwaitType->tp_alloc(__pyx_CoroutineAwaitType); __pyx_CoroutineAwaitObject *await = (__pyx_CoroutineAwaitObject*)
__pyx_CoroutineAwaitType->tp_new(__pyx_CoroutineAwaitType, __pyx_empty_tuple, NULL);
#endif #endif
if (unlikely(!await)) return NULL; if (unlikely(!await)) return NULL;
Py_INCREF(coroutine); Py_INCREF(coroutine);
...@@ -1102,10 +1109,12 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) { ...@@ -1102,10 +1109,12 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname); PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname);
#else #else
PyObject *msg; PyObject *msg;
char *cname, *cmsg; char *cmsg;
#if CYTHON_COMPILING_IN_PYPY #if CYTHON_COMPILING_IN_PYPY
msg = NULL; msg = NULL;
cmsg = (char*) "coroutine was never awaited";
#else #else
char *cname;
PyObject *qualname; PyObject *qualname;
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
qualname = PyUnicode_AsUTF8String(gen->gi_qualname); qualname = PyUnicode_AsUTF8String(gen->gi_qualname);
...@@ -1126,7 +1135,6 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) { ...@@ -1126,7 +1135,6 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
Py_XDECREF(qualname); Py_XDECREF(qualname);
#endif #endif
#endif
if (unlikely(!msg)) { if (unlikely(!msg)) {
PyErr_Clear(); PyErr_Clear();
...@@ -1138,6 +1146,7 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) { ...@@ -1138,6 +1146,7 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
cmsg = PyString_AS_STRING(msg); cmsg = PyString_AS_STRING(msg);
#endif #endif
} }
#endif
if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
PyErr_WriteUnraisable(self); PyErr_WriteUnraisable(self);
Py_XDECREF(msg); Py_XDECREF(msg);
......
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