summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-04-13 21:00:05 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-04-13 21:00:05 +0000
commit66afe6dc308db475d729fbd742d79da00e1955ca (patch)
treeb5ca0db96e37c45c1dc6919fe63c22f019b44808 /numpy/core/src
parent8a20ec0dd37e84c24bda059c6d76d56790c47c53 (diff)
downloadnumpy-66afe6dc308db475d729fbd742d79da00e1955ca.tar.gz
Fix so that b.shape = <tuple> does not work for non-contiguous arrays
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/arrayobject.c9
-rw-r--r--numpy/core/src/multiarraymodule.c4
2 files changed, 11 insertions, 2 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 8383c679c..e51b1bc3e 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -4480,9 +4480,16 @@ array_shape_set(PyArrayObject *self, PyObject *val)
{
int nd;
PyObject *ret;
-
+
+ /* Assumes C-order */
ret = PyArray_Reshape(self, val);
if (ret == NULL) return -1;
+ if (PyArray_DATA(ret) != PyArray_DATA(self)) {
+ Py_DECREF(ret);
+ PyErr_SetString(PyExc_AttributeError,
+ "setting the shape of a non-contiguous array");
+ return -1;
+ }
/* Free old dimensions and strides */
PyDimMem_FREE(self->dimensions);
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c
index 9982dec8f..740d3fd24 100644
--- a/numpy/core/src/multiarraymodule.c
+++ b/numpy/core/src/multiarraymodule.c
@@ -447,7 +447,9 @@ _fix_unknown_dimension(PyArray_Dims *newshape, intp s_original)
/* Returns a new array
with the new shape from the data
in the old array --- order-perspective depends on fortran argument.
- copy-if-necessary
+ copy-if-necessary (currently if not contiguous or fortran-contiguous)
+ perhaps a more general-purpose strategy for determining this can
+ be worked out
*/
/*MULTIARRAY_API