From 36a1ded3c1782830453318ddad24548626d16bf0 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Tue, 9 Mar 2010 21:28:44 -0300 Subject: [PATCH] fix buffer code and testcases to silent GCC warning --- Cython/Compiler/Buffer.py | 4 ++-- Cython/Compiler/ExprNodes.py | 4 ++-- tests/run/numpy_bufacc_T155.pyx | 2 ++ tests/run/numpy_common.pxi | 7 +++++++ tests/run/numpy_test.pyx | 2 ++ 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 tests/run/numpy_common.pxi diff --git a/Cython/Compiler/Buffer.py b/Cython/Compiler/Buffer.py index d7d66e82..bf6eef8b 100644 --- a/Cython/Compiler/Buffer.py +++ b/Cython/Compiler/Buffer.py @@ -723,8 +723,8 @@ typedef struct { } __Pyx_BufFmt_StackElem; +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -static int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); """, impl=""" static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; @@ -1131,7 +1131,7 @@ static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->suboffsets = __Pyx_minusones; } -static int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { if (obj == Py_None) { __Pyx_ZeroBuffer(buf); return 0; diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 209c1a80..bec609cd 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -3440,8 +3440,6 @@ class SequenceNode(ExprNode): # allocates the temps in a rather hacky way -- the assignment # is evaluated twice, within each if-block. - code.globalstate.use_utility_code(unpacking_utility_code) - if rhs.type is tuple_type: tuple_check = "likely(%s != Py_None)" else: @@ -3477,6 +3475,8 @@ class SequenceNode(ExprNode): rhs.py_result(), len(self.args))) code.putln(code.error_goto(self.pos)) else: + code.globalstate.use_utility_code(unpacking_utility_code) + self.iterator.allocate(code) code.putln( "%s = PyObject_GetIter(%s); %s" % ( diff --git a/tests/run/numpy_bufacc_T155.pyx b/tests/run/numpy_bufacc_T155.pyx index 7d0bb6b0..38549a02 100644 --- a/tests/run/numpy_bufacc_T155.pyx +++ b/tests/run/numpy_bufacc_T155.pyx @@ -13,3 +13,5 @@ def myfunc(): for i from 0 <= i < A.shape[0]: A[i, :] /= 2 return A[0,0] + +include "numpy_common.pxi" diff --git a/tests/run/numpy_common.pxi b/tests/run/numpy_common.pxi new file mode 100644 index 00000000..ad6e7b08 --- /dev/null +++ b/tests/run/numpy_common.pxi @@ -0,0 +1,7 @@ +cdef extern from *: + void import_array() + void import_umath() + +if 0: + import_array() + import_umath() diff --git a/tests/run/numpy_test.pyx b/tests/run/numpy_test.pyx index 187737d0..2f9801d9 100644 --- a/tests/run/numpy_test.pyx +++ b/tests/run/numpy_test.pyx @@ -428,3 +428,5 @@ def test_point_record(): test[i].x = i test[i].y = -i print repr(test).replace('<', '!').replace('>', '!') + +include "numpy_common.pxi" -- 2.26.2