diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-09-25 10:55:24 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2017-09-25 16:42:21 -0600 |
commit | afbcc7ea62d2c39126d417d0309677f005b2a12c (patch) | |
tree | 35d211bffe8e64095a2300cc1dd2c40a8837e0a6 | |
parent | bac743beff16d596363e0f7ad4570a7a6bfe7fe5 (diff) | |
download | numpy-afbcc7ea62d2c39126d417d0309677f005b2a12c.tar.gz |
MAINT,BUG: Fix mtrand for Cython 0.27.
The `import_array()` macro, that defined a C code block that included a
return, was not handled correctly. The fix here is to cdef a replacement
`import_array` function with a defined error return. The new function is
a slight variation of the corresponding function defined by Cython.
-rw-r--r-- | numpy/random/mtrand/numpy.pxd | 12 | ||||
-rwxr-xr-x | tools/travis-before-install.sh | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/numpy/random/mtrand/numpy.pxd b/numpy/random/mtrand/numpy.pxd index 32b19c1ab..db6265238 100644 --- a/numpy/random/mtrand/numpy.pxd +++ b/numpy/random/mtrand/numpy.pxd @@ -1,4 +1,5 @@ # :Author: Travis Oliphant +from cpython.exc cimport PyErr_Print cdef extern from "numpy/npy_no_deprecated_api.h": pass @@ -134,7 +135,7 @@ cdef extern from "numpy/arrayobject.h": dtype PyArray_DescrFromType(int) - void import_array() + int _import_array() except -1 # include functions that were once macros in the new api @@ -151,3 +152,12 @@ cdef extern from "numpy/arrayobject.h": int PyArray_TYPE(ndarray arr) int PyArray_CHKFLAGS(ndarray arr, int flags) object PyArray_GETITEM(ndarray arr, char *itemptr) + + +# copied from cython version with addition of PyErr_Print. +cdef inline int import_array() except -1: + try: + _import_array() + except Exception: + PyErr_Print() + raise ImportError("numpy.core.multiarray failed to import") diff --git a/tools/travis-before-install.sh b/tools/travis-before-install.sh index 3203658d5..5e5278ce5 100755 --- a/tools/travis-before-install.sh +++ b/tools/travis-before-install.sh @@ -26,6 +26,6 @@ fi source venv/bin/activate python -V pip install --upgrade pip setuptools -pip install nose pytz cython==0.26 +pip install nose pytz cython if [ -n "$USE_ASV" ]; then pip install asv; fi popd |