[Numpy-svn] r3721 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Fri Apr 20 15:27:06 CDT 2007


Author: oliphant
Date: 2007-04-20 15:27:01 -0500 (Fri, 20 Apr 2007)
New Revision: 3721

Modified:
   trunk/numpy/core/src/arrayobject.c
Log:
Fix byte-swapping error on conversion to Object array from big-endian array (byte-swapping was happening twice in that case).  This fixes #503.

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2007-04-20 12:12:43 UTC (rev 3720)
+++ trunk/numpy/core/src/arrayobject.c	2007-04-20 20:27:01 UTC (rev 3721)
@@ -7732,12 +7732,18 @@
                 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);
 }



More information about the Numpy-svn mailing list