summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorLuis Pedro Coelho <luis@luispedro.org>2012-12-03 11:06:02 +0000
committerLuis Pedro Coelho <luis@luispedro.org>2012-12-03 11:06:02 +0000
commit7855b2605d96a5b9efe1ae48cb8d7554caaba1de (patch)
tree1cb3ff809de75d5cea9e35031286263c95daed05 /numpy
parenta289be867f810e076eec4558610032bf4bc5a174 (diff)
downloadnumpy-7855b2605d96a5b9efe1ae48cb8d7554caaba1de.tar.gz
API Make PyArray_DATA return void*
PyArray_DATA is documented as returning void*. Changing it to return char* breaks code such as (in C++):: float* my_floats = static_cast<float*>(PyArray_DATA(my_array)); PyArray_BYTES returns char*, but is otherwise the same function.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/include/numpy/ndarraytypes.h13
-rw-r--r--numpy/core/src/multiarray/getset.c2
2 files changed, 9 insertions, 6 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h
index c84eb6277..5bb6fa106 100644
--- a/numpy/core/include/numpy/ndarraytypes.h
+++ b/numpy/core/include/numpy/ndarraytypes.h
@@ -1390,12 +1390,18 @@ PyArray_NDIM(const PyArrayObject *arr)
return ((PyArrayObject_fields *)arr)->nd;
}
-static NPY_INLINE char *
+static NPY_INLINE void *
PyArray_DATA(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->data;
}
+static NPY_INLINE char *
+PyArray_BYTES(PyArrayObject *arr)
+{
+ return ((PyArrayObject_fields *)arr)->data;
+}
+
static NPY_INLINE npy_intp *
PyArray_DIMS(PyArrayObject *arr)
{
@@ -1470,15 +1476,12 @@ PyArray_SETITEM(PyArrayObject *arr, char *itemptr, PyObject *v)
v, itemptr, arr);
}
-/* Same as PyArray_DATA */
-#define PyArray_BYTES(arr) PyArray_DATA(arr)
-
#else
/* These macros are deprecated as of NumPy 1.7. */
#define PyArray_NDIM(obj) (((PyArrayObject_fields *)(obj))->nd)
#define PyArray_BYTES(obj) (((PyArrayObject_fields *)(obj))->data)
-#define PyArray_DATA(obj) (((PyArrayObject_fields *)(obj))->data)
+#define PyArray_DATA(obj) ((void *)((PyArrayObject_fields *)(obj))->data)
#define PyArray_DIMS(obj) (((PyArrayObject_fields *)(obj))->dimensions)
#define PyArray_STRIDES(obj) (((PyArrayObject_fields *)(obj))->strides)
#define PyArray_DIM(obj,n) (PyArray_DIMS(obj)[n])
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index acefa888d..7106e7a13 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -131,7 +131,7 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
if (PyArray_BASE(new) && PyObject_AsReadBuffer(PyArray_BASE(new),
(const void **)&buf,
&buf_len) >= 0) {
- offset = PyArray_DATA(self) - buf;
+ offset = PyArray_BYTES(self) - buf;
numbytes = buf_len + offset;
}
else {