- Issue #10181: New memoryview implementation fixes multiple ownership
and lifetime issues of dynamically allocated Py_buffer members (#9990)
as well as crashes (#8305, #7433). Many new features have been added
(See whatsnew/3.3), and the documentation has been updated extensively.
The ndarray test object from _testbuffer.c implements all aspects of
PEP-3118, so further development towards the complete implementation
of the PEP can proceed in a test-driven manner.
Thanks to Nick Coghlan, Antoine Pitrou and Pauli Virtanen for review
and many ideas.
- Issue #12834: Fix incorrect results of memoryview.tobytes() for
non-contiguous arrays.
- Issue #5231: Introduce memoryview.cast() method that allows changing
format and shape without making a copy of the underlying memory.
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 47010d6..62fccdc 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -340,7 +340,7 @@
}
static int
-_IsFortranContiguous(Py_buffer *view)
+_IsFortranContiguous(const Py_buffer *view)
{
Py_ssize_t sd, dim;
int i;
@@ -361,7 +361,7 @@
}
static int
-_IsCContiguous(Py_buffer *view)
+_IsCContiguous(const Py_buffer *view)
{
Py_ssize_t sd, dim;
int i;
@@ -382,16 +382,16 @@
}
int
-PyBuffer_IsContiguous(Py_buffer *view, char fort)
+PyBuffer_IsContiguous(const Py_buffer *view, char order)
{
if (view->suboffsets != NULL) return 0;
- if (fort == 'C')
+ if (order == 'C')
return _IsCContiguous(view);
- else if (fort == 'F')
+ else if (order == 'F')
return _IsFortranContiguous(view);
- else if (fort == 'A')
+ else if (order == 'A')
return (_IsCContiguous(view) || _IsFortranContiguous(view));
return 0;
}
@@ -651,7 +651,7 @@
PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len,
int readonly, int flags)
{
- if (view == NULL) return 0;
+ if (view == NULL) return 0; /* XXX why not -1? */
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
(readonly == 1)) {
PyErr_SetString(PyExc_BufferError,