summaryrefslogtreecommitdiff
path: root/numpy/core/src
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
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')
-rw-r--r--numpy/core/src/arraymethods.c15
-rw-r--r--numpy/core/src/arrayobject.c1
-rw-r--r--numpy/core/src/arraytypes.inc.src5
3 files changed, 19 insertions, 2 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);
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index f82cc8d57..1d674fb5f 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -8824,6 +8824,7 @@ arraydescr_setstate(PyArray_Descr *self, PyObject *args)
/*OBJECT_API
Deep bytorder change of a data-type descriptor
+ *** Leaves reference count of self unchanged --- does not DECREF self ***
*/
static PyArray_Descr *
PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.inc.src
index 4bd24904a..95a7121b1 100644
--- a/numpy/core/src/arraytypes.inc.src
+++ b/numpy/core/src/arraytypes.inc.src
@@ -1203,7 +1203,10 @@ STRING_copyswapn (char *dst, char *src, intp n, int swap, int itemsize)
return;
}
-/* ignore swap */
+/* ignore swap
+
+TODO: Need descriptor argument and then recurse down fields
+*/
static void
VOID_copyswapn (char *dst, char *src, intp n, int swap, int itemsize)
{