Commit 5f35da28 authored by Stefan Behnel's avatar Stefan Behnel

fix format checking for cython.array.__getbuffer__() in Py3

--HG--
extra : amend_source : 685e555a2102e496280287b3b7605d67d694ff40
parent 6056c8c4
......@@ -16,6 +16,9 @@ Features added
Bugs fixed
----------
* Format checking when requesting non-contiguous buffers from
``cython.array`` objects was disabled in Py3.
* C++ destructor calls in extension types could fail to compile in clang.
* Buffer format validation failed for sequences of strings in structs.
......
......@@ -150,16 +150,15 @@ cdef class array:
self._shape[idx] = dim
idx += 1
if mode not in ("fortran", "c"):
raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
cdef char order
if mode == 'fortran':
order = 'F'
order = b'F'
self.mode = u'fortran'
else:
order = 'C'
elif mode == 'c':
order = b'C'
self.mode = u'c'
else:
raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
self.len = fill_contig_strides_array(self._shape, self._strides,
itemsize, self.ndim, order)
......@@ -180,9 +179,9 @@ cdef class array:
@cname('getbuffer')
def __getbuffer__(self, Py_buffer *info, int flags):
cdef int bufmode = -1
if self.mode == b"c":
if self.mode == u"c":
bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
elif self.mode == b"fortran":
elif self.mode == u"fortran":
bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
if not (flags & bufmode):
raise ValueError("Can only create a buffer that is contiguous in memory.")
......
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