diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-08-08 05:13:02 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-08-08 05:13:02 +0000 |
commit | 50a50441a148a9ea3fbc1629e065d88a4f28a419 (patch) | |
tree | cc974798d0e964f7c55f160e8e16bb5cce8f4eaa /numpy/core/src/arraymethods.c | |
parent | fec6f0838c8c35709f4e8ef6753f6a1e5a88647c (diff) | |
download | numpy-50a50441a148a9ea3fbc1629e065d88a4f28a419.tar.gz |
Fix segfault in Ticket #238
Diffstat (limited to 'numpy/core/src/arraymethods.c')
-rw-r--r-- | numpy/core/src/arraymethods.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c index e13061a4e..cc885b90f 100644 --- a/numpy/core/src/arraymethods.c +++ b/numpy/core/src/arraymethods.c @@ -359,6 +359,12 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace) copyswapn = self->descr->f->copyswapn; if (inplace) { + if (!PyArray_ISWRITEABLE(self)) { + PyErr_SetString(PyExc_RuntimeError, + "Cannot byte-swap in-place on a " \ + "read-only array"); + return NULL; + } size = PyArray_SIZE(self); if (PyArray_ISONESEGMENT(self)) { copyswapn(self->data, self->descr->elsize, NULL, -1, size, 1, self); |