summaryrefslogtreecommitdiff
path: root/numpy/core/src/arraymethods.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-04-11 07:14:15 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-04-11 07:14:15 +0000
commit5326f8922066ad8e3adc27ef26b75fd6d4d2b895 (patch)
tree0543cc7716da0c6d499b383d02b6459f22e0aa00 /numpy/core/src/arraymethods.c
parentc71689e56764c93535481273c6a2be857ac08764 (diff)
downloadnumpy-5326f8922066ad8e3adc27ef26b75fd6d4d2b895.tar.gz
Comment changes. Fix-up byte-swapping on pickle read so that descriptor is also changed.
Diffstat (limited to 'numpy/core/src/arraymethods.c')
-rw-r--r--numpy/core/src/arraymethods.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c
index 29d7105f8..cf4a7faae 100644
--- a/numpy/core/src/arraymethods.c
+++ b/numpy/core/src/arraymethods.c
@@ -1028,9 +1028,22 @@ array_setstate(PyArrayObject *self, PyObject *args)
return PyErr_NoMemory();
}
if (swap) { /* byte-swap on pickle-read */
+ intp numels = num / self->descr->elsize;
self->descr->f->copyswapn(self->data, datastr,
- num, 1,
+ numels,
+ 1,
self->descr->elsize);
+ if (!PyArray_ISEXTENDED(self)) {
+ self->descr = PyArray_DescrFromType(self->descr->type_num);
+ }
+ else {
+ self->descr = PyArray_DescrNew(typecode);
+ if (self->descr->byteorder == PyArray_BIG)
+ self->descr->byteorder = PyArray_LITTLE;
+ else if (self->descr->byteorder == PyArray_LITTLE)
+ self->descr->byteorder = PyArray_BIG;
+ }
+ Py_DECREF(typecode);
}
else {
memcpy(self->data, datastr, num);