summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
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/arrayobject.c
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/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c9
1 files changed, 8 insertions, 1 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);