[Cython] gcc error when compiling cython
Stefan Behnel
stefan_ml at behnel.de
Sat Aug 22 08:29:49 CEST 2015
Thomas Holenstein schrieb am 17.08.2015 um 11:29:
> recently, I had a gcc compile time error with cython. The work around
> is obvious, as the problem happens when a cdef-ed numpy array in a
> function is unused. Nevertheless, I feel it's useful to report the
> problem I had.
>
> The following is a test case
> ---------------------------------------- test.pyx
> import numpy as np
> cimport numpy as np
>
> def f(np.ndarray[dtype=np.int_t, ndim=2] arg1):
> cdef np.ndarray[dtype=np.int_t, ndim=2] arr
> return 3
> ----------------------------------------- setup.py
> from distutils.core import setup
> from Cython.Build import cythonize
>
> setup(
> ext_modules = cythonize("test.pyx"),
> )
> ----------------------------------------------------------
> This gives me the error
>
> error: ‘__pyx_pybuffernd_arr’ undeclared
>
> Full shell output:
> ~/tmp/ctest > python setup.py build_ext --inplace
> running build_ext
> building 'test' extension
> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv
> -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c test.c
> -o build/temp.linux-x86_64-2.7/test.o
> test.c: In function ‘__pyx_pf_4test_f’:
> test.c:1240:30: error: ‘__pyx_pybuffernd_arr’ undeclared (first use in
> this function)
> __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
Looks like this long-standing ticket:
http://trac.cython.org/ticket/154
Here's a fix:
https://github.com/cython/cython/commit/d2c1b7770571061492996e90b45a633f2f83a66a
Stefan
More information about the cython-devel
mailing list