diff options
author | Robert Bradshaw <robertwb@gmail.com> | 2017-08-25 01:23:51 -0700 |
---|---|---|
committer | Robert Bradshaw <robertwb@gmail.com> | 2017-08-25 01:23:51 -0700 |
commit | 61f614f70e5f88efbd0f25a1d074609d9d58d817 (patch) | |
tree | af2e6d455853727dc3a506354a3ec90fd4a19cdb | |
parent | cbc3c84c5d6a35962f5d8800b73db2fe678735d1 (diff) | |
parent | 07c52660a5a9fec11bdf86744a4a06c45c76bf1a (diff) | |
download | cython-61f614f70e5f88efbd0f25a1d074609d9d58d817.tar.gz |
Merge branch 'master' of github.com:cython/cython
-rw-r--r-- | Cython/Compiler/TypeInference.py | 3 | ||||
-rw-r--r-- | Cython/Utility/AsyncGen.c | 30 | ||||
-rw-r--r-- | Cython/Utility/Coroutine.c | 42 |
3 files changed, 50 insertions, 25 deletions
diff --git a/Cython/Compiler/TypeInference.py b/Cython/Compiler/TypeInference.py index 5137f2513..c09220c06 100644 --- a/Cython/Compiler/TypeInference.py +++ b/Cython/Compiler/TypeInference.py @@ -307,8 +307,7 @@ class MarkOverflowingArithmetic(CythonTransform): return self.visit_dangerous_node(node) def visit_SimpleCallNode(self, node): - if (isinstance(node.function, ExprNodes.NameNode) - and node.function.name == 'abs'): + if node.function.is_name and node.function.name == 'abs': # Overflows for minimum value of fixed size ints. return self.visit_dangerous_node(node) else: diff --git a/Cython/Utility/AsyncGen.c b/Cython/Utility/AsyncGen.c index 238fe4011..4539cc2f0 100644 --- a/Cython/Utility/AsyncGen.c +++ b/Cython/Utility/AsyncGen.c @@ -13,8 +13,6 @@ typedef struct { int ag_closed; } __pyx_PyAsyncGenObject; -typedef struct __pyx_PyAsyncGenASend_struct __pyx_PyAsyncGenASend; - static PyTypeObject *__pyx__PyAsyncGenWrappedValueType = 0; static PyTypeObject *__pyx__PyAsyncGenASendType = 0; static PyTypeObject *__pyx__PyAsyncGenAThrowType = 0; @@ -23,10 +21,14 @@ static PyTypeObject *__pyx_AsyncGenType = 0; #define __Pyx_AsyncGen_CheckExact(obj) (Py_TYPE(obj) == __pyx_AsyncGenType) #define __pyx_PyAsyncGenASend_CheckExact(o) \ (Py_TYPE(o) == __pyx__PyAsyncGenASendType) +#define __pyx_PyAsyncGenAThrow_CheckExact(o) \ + (Py_TYPE(o) == __pyx__PyAsyncGenAThrowType) -static PyObject *__Pyx_async_gen_anext(__pyx_PyAsyncGenObject *o); -static CYTHON_INLINE PyObject *__Pyx_async_gen_asend_iternext(__pyx_PyAsyncGenASend *o); -static PyObject *__Pyx_async_gen_asend_send(__pyx_PyAsyncGenASend *o, PyObject *arg); +static PyObject *__Pyx_async_gen_anext(PyObject *o); +static CYTHON_INLINE PyObject *__Pyx_async_gen_asend_iternext(PyObject *o); +static PyObject *__Pyx_async_gen_asend_send(PyObject *o, PyObject *arg); +static PyObject *__Pyx_async_gen_asend_close(PyObject *o, PyObject *args); +static PyObject *__Pyx_async_gen_athrow_close(PyObject *o, PyObject *args); static PyObject *__Pyx__PyAsyncGenValueWrapperNew(PyObject *val); @@ -131,7 +133,7 @@ typedef enum { __PYX_AWAITABLE_STATE_CLOSED, /* closed */ } __pyx_AwaitableState; -struct __pyx_PyAsyncGenASend_struct { +typedef struct { PyObject_HEAD __pyx_PyAsyncGenObject *ags_gen; @@ -139,7 +141,7 @@ struct __pyx_PyAsyncGenASend_struct { PyObject *ags_sendval; __pyx_AwaitableState ags_state; -}; +} __pyx_PyAsyncGenASend; typedef struct { @@ -237,8 +239,9 @@ __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o) static PyObject * -__Pyx_async_gen_anext(__pyx_PyAsyncGenObject *o) +__Pyx_async_gen_anext(PyObject *g) { + __pyx_PyAsyncGenObject *o = (__pyx_PyAsyncGenObject*) g; if (__Pyx_async_gen_init_hooks(o)) { return NULL; } @@ -478,8 +481,9 @@ __Pyx_async_gen_asend_traverse(__pyx_PyAsyncGenASend *o, visitproc visit, void * static PyObject * -__Pyx_async_gen_asend_send(__pyx_PyAsyncGenASend *o, PyObject *arg) +__Pyx_async_gen_asend_send(PyObject *g, PyObject *arg) { + __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g; PyObject *result; if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) { @@ -506,7 +510,7 @@ __Pyx_async_gen_asend_send(__pyx_PyAsyncGenASend *o, PyObject *arg) static CYTHON_INLINE PyObject * -__Pyx_async_gen_asend_iternext(__pyx_PyAsyncGenASend *o) +__Pyx_async_gen_asend_iternext(PyObject *o) { return __Pyx_async_gen_asend_send(o, Py_None); } @@ -534,8 +538,9 @@ __Pyx_async_gen_asend_throw(__pyx_PyAsyncGenASend *o, PyObject *args) static PyObject * -__Pyx_async_gen_asend_close(__pyx_PyAsyncGenASend *o, CYTHON_UNUSED PyObject *args) +__Pyx_async_gen_asend_close(PyObject *g, CYTHON_UNUSED PyObject *args) { + __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g; o->ags_state = __PYX_AWAITABLE_STATE_CLOSED; Py_RETURN_NONE; } @@ -920,8 +925,9 @@ __Pyx_async_gen_athrow_iternext(__pyx_PyAsyncGenAThrow *o) static PyObject * -__Pyx_async_gen_athrow_close(__pyx_PyAsyncGenAThrow *o, CYTHON_UNUSED PyObject *args) +__Pyx_async_gen_athrow_close(PyObject *g, CYTHON_UNUSED PyObject *args) { + __pyx_PyAsyncGenAThrow *o = (__pyx_PyAsyncGenAThrow*) g; o->agt_state = __PYX_AWAITABLE_STATE_CLOSED; Py_RETURN_NONE; } diff --git a/Cython/Utility/Coroutine.c b/Cython/Utility/Coroutine.c index b7b654687..e8d25b63d 100644 --- a/Cython/Utility/Coroutine.c +++ b/Cython/Utility/Coroutine.c @@ -90,7 +90,7 @@ static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject #ifdef __Pyx_AsyncGen_USED // inlined "__pyx_PyAsyncGenASend" handling to avoid the series of generic calls below } else if (__pyx_PyAsyncGenASend_CheckExact(source)) { - retval = __Pyx_async_gen_asend_iternext((__pyx_PyAsyncGenASend *)source); + retval = __Pyx_async_gen_asend_iternext(source); if (retval) { Py_INCREF(source); gen->yieldfrom = source; @@ -299,7 +299,7 @@ static PyObject *__Pyx__Coroutine_AsyncIterNext(PyObject *obj) { static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) { #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(obj)) { - return __Pyx_async_gen_anext((__pyx_PyAsyncGenObject*) obj); + return __Pyx_async_gen_anext(obj); } #endif #if CYTHON_USE_ASYNC_SLOTS @@ -402,6 +402,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); /*proto*/ static PyTypeObject *__pyx_CoroutineType = 0; static PyTypeObject *__pyx_CoroutineAwaitType = 0; #define __Pyx_Coroutine_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineType) +#define __Pyx_CoroutineAwait_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineAwaitType) #define __Pyx_Coroutine_New(body, closure, name, qualname, module_name) \ __Pyx__Coroutine_New(__pyx_CoroutineType, body, closure, name, qualname, module_name) @@ -409,6 +410,14 @@ static PyTypeObject *__pyx_CoroutineAwaitType = 0; static int __pyx_Coroutine_init(void); /*proto*/ static PyObject *__Pyx__Coroutine_await(PyObject *coroutine); /*proto*/ +typedef struct { + PyObject_HEAD + PyObject *coroutine; +} __pyx_CoroutineAwaitObject; + +static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self); /*proto*/ +static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args); /*proto*/ + //////////////////// Generator.proto //////////////////// @@ -730,7 +739,7 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_PyAsyncGenASend_CheckExact(yf)) { - ret = __Pyx_async_gen_asend_send((__pyx_PyAsyncGenASend *)yf, value); + ret = __Pyx_async_gen_asend_send(yf, value); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 @@ -780,6 +789,21 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { if (!retval) return -1; } else + if (__Pyx_CoroutineAwait_CheckExact(yf)) { + retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + retval = __Pyx_async_gen_asend_close(yf, NULL); + // cannot fail + } else + if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { + retval = __Pyx_async_gen_athrow_close(yf, NULL); + // cannot fail + } else #endif { PyObject *meth; @@ -914,11 +938,12 @@ static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject #ifdef __Pyx_Coroutine_USED || __Pyx_Coroutine_CheckExact(yf) #endif - #ifdef __Pyx_AsyncGen_USED - || __Pyx_AsyncGen_CheckExact(yf) - #endif ) { ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { + ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); + #endif } else { PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, PYIDENT("throw")); if (unlikely(!meth)) { @@ -1275,11 +1300,6 @@ static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( //@requires: CoroutineBase //@requires: PatchGeneratorABC -typedef struct { - PyObject_HEAD - PyObject *coroutine; -} __pyx_CoroutineAwaitObject; - static void __Pyx_CoroutineAwait_dealloc(PyObject *self) { PyObject_GC_UnTrack(self); Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine); |