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 /numpy | |
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.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/random/mtrand/numpy.pxd | 12 |
1 files changed, 11 insertions, 1 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") |