From: Dag Sverre Seljebotn Date: Tue, 28 Apr 2009 13:02:09 +0000 (+0200) Subject: Simple fix for #155 X-Git-Tag: 0.11.2.rc1~10^2~36^2~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5ddddeede553e60ea922c3a1545e692eaa572b86;p=cython.git Simple fix for #155 --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index b8d41ec0..c1bc8ea4 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1705,8 +1705,6 @@ class IndexNode(ExprNode): if self.indices: indices = self.indices else: - # On cloning, indices is cloned. Otherwise, unpack index into indices - assert not isinstance(self.index, CloneNode) if isinstance(self.index, TupleNode): indices = self.index.args else: @@ -1719,6 +1717,9 @@ class IndexNode(ExprNode): if not x.type.is_int: buffer_access = False + # On cloning, indices is cloned. Otherwise, unpack index into indices + assert not (buffer_access and isinstance(self.index, CloneNode)) + if buffer_access: self.indices = indices self.index = None diff --git a/Cython/Compiler/Visitor.py b/Cython/Compiler/Visitor.py index c7739f8d..6e40d858 100644 --- a/Cython/Compiler/Visitor.py +++ b/Cython/Compiler/Visitor.py @@ -150,6 +150,7 @@ class TreeVisitor(BasicVisitor): except Errors.CompileError: raise except Exception, e: + raise import sys trace = [''] for parent, attribute, index in self.access_path: diff --git a/tests/run/numpy_bufacc_T155.pyx b/tests/run/numpy_bufacc_T155.pyx new file mode 100644 index 00000000..7d0bb6b0 --- /dev/null +++ b/tests/run/numpy_bufacc_T155.pyx @@ -0,0 +1,15 @@ +""" +>>> myfunc() +0.5 +""" + +cimport numpy as np +import numpy as np + +def myfunc(): + cdef np.ndarray[float, ndim=2] A = np.ones((1,1), dtype=np.float32) + cdef int i + + for i from 0 <= i < A.shape[0]: + A[i, :] /= 2 + return A[0,0]