Commit 7551bd22 authored by Stefan Behnel's avatar Stefan Behnel

fix compiler crash on in-place buffer C division

parent 52af0421
......@@ -4533,7 +4533,8 @@ class InPlaceAssignmentNode(AssignmentNode):
if isinstance(self.lhs, ExprNodes.IndexNode) and self.lhs.is_buffer_access:
if self.lhs.type.is_pyobject:
error(self.pos, "In-place operators not allowed on object buffers in this release.")
if c_op in ('/', '%') and self.lhs.type.is_int and not code.directives['cdivision']:
if (c_op in ('/', '%') and self.lhs.type.is_int
and not code.globalstate.directives['cdivision']):
error(self.pos, "In-place non-c divide operators not allowed on int buffers.")
self.lhs.generate_buffer_setitem_code(self.rhs, code, c_op)
else:
......
# mode: run
# tag: memoryview, cdivision
cimport cython
from cpython.array cimport array # make Cython aware of the array type
def div_memoryview(int[:] A):
"""
>>> from array import array
>>> x = array('i', [6])
>>> div_memoryview(x)
>>> x[0]
3
"""
with cython.cdivision(True):
A[0] /= 2
def div_buffer(object[int, ndim=1] A):
"""
>>> from array import array
>>> x = array('i', [6])
>>> div_buffer(x)
>>> x[0]
3
"""
with cython.cdivision(True):
A[0] /= 2
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