diff options
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); |