diff options
author | Travis Oliphant <oliphant@enthought.com> | 2007-04-20 20:27:01 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2007-04-20 20:27:01 +0000 |
commit | 41861b55aa74fb5aab11e2d101f997d8d36389e7 (patch) | |
tree | ae543e5b29ae26087c3871583ab7f8a8d6a2b1dc /numpy/core/src/arrayobject.c | |
parent | e52ea92ca1859203ce3ffd569f777e532cbdc260 (diff) | |
download | numpy-41861b55aa74fb5aab11e2d101f997d8d36389e7.tar.gz |
Fix byte-swapping error on conversion to Object array from big-endian array (byte-swapping was happening twice in that case). This fixes #503.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 199189b8f..e16e92ec8 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -7732,12 +7732,18 @@ PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp) if (!PyArray_ISNUMBER(mp) && PyErr_Occurred()) return -1; } - /* If the input or output is STRING, UNICODE, or VOID */ + /* If the input or output is OBJECT, STRING, UNICODE, or VOID */ /* then getitem and setitem are used for the cast */ /* and byteswapping is handled by those methods */ - iswap = PyArray_ISBYTESWAPPED(mp) && !PyArray_ISFLEXIBLE(mp); - oswap = PyArray_ISBYTESWAPPED(out) && !PyArray_ISFLEXIBLE(out); + if (PyArray_ISFLEXIBLE(mp) || PyArray_ISOBJECT(mp) || PyArray_ISOBJECT(out) || + PyArray_ISFLEXIBLE(out)) { + iswap = oswap = 0; + } + else { + iswap = PyArray_ISBYTESWAPPED(mp); + oswap = PyArray_ISBYTESWAPPED(out); + } return _broadcast_cast(out, mp, castfunc, iswap, oswap); } |