Skip to content

Commit

Permalink
Merge pull request numpy#21798 from karlotness/maint-import-array-err
Browse files Browse the repository at this point in the history
MAINT: use PyErr_SetString in _import_array where possible
  • Loading branch information
charris authored Jun 21, 2022
2 parents 7fdb7a4 + fb73e4e commit 0028203
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions numpy/core/code_generators/generate_numpy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@
*/
st = PyArray_GetEndianness();
if (st == NPY_CPU_UNKNOWN_ENDIAN) {
PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as unknown endian");
PyErr_SetString(PyExc_RuntimeError,
"FATAL: module compiled as unknown endian");
return -1;
}
#if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
if (st != NPY_CPU_BIG) {
PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as "\
"big endian, but detected different endianness at runtime");
PyErr_SetString(PyExc_RuntimeError,
"FATAL: module compiled as big endian, but "
"detected different endianness at runtime");
return -1;
}
#elif NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
if (st != NPY_CPU_LITTLE) {
PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as "\
"little endian, but detected different endianness at runtime");
PyErr_SetString(PyExc_RuntimeError,
"FATAL: module compiled as little endian, but "
"detected different endianness at runtime");
return -1;
}
#endif
Expand Down

0 comments on commit 0028203

Please sign in to comment.