[Numpy-svn] r6198 - trunk/numpy/core/code_generators

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Dec 27 00:57:08 EST 2008


Author: cdavid
Date: 2008-12-26 23:56:58 -0600 (Fri, 26 Dec 2008)
New Revision: 6198

Modified:
   trunk/numpy/core/code_generators/generate_numpy_api.py
Log:
BUG: Add a runtime check about endianness, to detect bug 4728 in python on Mac OS X.

Modified: trunk/numpy/core/code_generators/generate_numpy_api.py
===================================================================
--- trunk/numpy/core/code_generators/generate_numpy_api.py	2008-12-26 14:39:55 UTC (rev 6197)
+++ trunk/numpy/core/code_generators/generate_numpy_api.py	2008-12-27 05:56:58 UTC (rev 6198)
@@ -65,6 +65,11 @@
 static int
 _import_array(void)
 {
+  union {
+    long i;
+    char c[sizeof(long)];
+  } bint = {1};
+
   PyObject *numpy = PyImport_ImportModule("numpy.core.multiarray");
   PyObject *c_api = NULL;
   if (numpy == NULL) return -1;
@@ -83,6 +88,17 @@
         (int) NPY_VERSION, (int) PyArray_GetNDArrayCVersion());
     return -1;
   }
+
+#ifdef WORDS_BIGENDIAN
+  if (bint.c[0] == 1) {
+    PyErr_Format(PyExc_RuntimeError, "module compiled against "\
+        "python headers configured as big endian, but little endian arch "\
+        "detected: this is a python 2.6.* bug (see bug 4728 in python bug "\
+        "tracker )");
+    return -1;
+  }
+#endif
+
   return 0;
 }
 




More information about the Numpy-svn mailing list