From ed4b0e7b189b9edf665a00f5220d60b4de24a391 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Sat, 16 Aug 2008 00:18:55 +0200 Subject: [PATCH] Raise compilation error on object[object] inplace operators (which are buggy) --- Cython/Compiler/Nodes.py | 4 +++- Cython/Includes/numpy.pxd | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index a9d5786d..7705997b 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2532,7 +2532,10 @@ class InPlaceAssignmentNode(AssignmentNode): extra = ", Py_None" else: extra = "" + import ExprNodes if self.lhs.type.is_pyobject: + if isinstance(self.lhs, ExprNodes.IndexNode) and self.lhs.is_buffer_access: + error(self.pos, "In-place operators not allowed on object buffers in this release.") self.dup.generate_result_code(code) code.putln( "%s = %s(%s, %s%s); %s" % ( @@ -2556,7 +2559,6 @@ class InPlaceAssignmentNode(AssignmentNode): else: error(self.pos, "No C inplace power operator") # have to do assignment directly to avoid side-effects - import ExprNodes if isinstance(self.lhs, ExprNodes.IndexNode) and self.lhs.is_buffer_access: self.lhs.generate_buffer_setitem_code(self.rhs, code, c_op) else: diff --git a/Cython/Includes/numpy.pxd b/Cython/Includes/numpy.pxd index 7f365967..97bb3037 100644 --- a/Cython/Includes/numpy.pxd +++ b/Cython/Includes/numpy.pxd @@ -102,3 +102,22 @@ cdef extern from "numpy/arrayobject.h": ctypedef float npy_float96 ctypedef float npy_float128 + +ctypedef npy_int8 int8_t +ctypedef npy_int16 int16_t +ctypedef npy_int32 int32_t +ctypedef npy_int64 int64_t +ctypedef npy_int96 int96_t +ctypedef npy_int128 int128_t + +ctypedef npy_uint8 uint8_t +ctypedef npy_uint16 uint16_t +ctypedef npy_uint32 uint32_t +ctypedef npy_uint64 uint64_t +ctypedef npy_uint96 uint96_t +ctypedef npy_uint128 uint128_t + +ctypedef npy_float32 float32_t +ctypedef npy_float64 float64_t +ctypedef npy_float80 float80_t +ctypedef npy_float128 float128_t -- 2.26.2