diff options
author | David Cournapeau <cournape@gmail.com> | 2008-12-27 05:56:58 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-12-27 05:56:58 +0000 |
commit | 7d1612d1721bfb04289df1684125b223b236b805 (patch) | |
tree | 147978bca48b03a6200d8ded5ad698090c09f2d4 /numpy | |
parent | ae88804358febeeedc0fdeb7d88a5a26473f7fca (diff) | |
download | numpy-7d1612d1721bfb04289df1684125b223b236b805.tar.gz |
BUG: Add a runtime check about endianness, to detect bug 4728 in python on Mac OS X.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/code_generators/generate_numpy_api.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py index 9cbc317ac..bc1e9f5e8 100644 --- a/numpy/core/code_generators/generate_numpy_api.py +++ b/numpy/core/code_generators/generate_numpy_api.py @@ -65,6 +65,11 @@ static void **PyArray_API=NULL; 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 @@ _import_array(void) (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; } |