[Cython] Strange bug? with np.int64_t

Stefan Behnel stefan_ml at behnel.de
Mon Nov 3 11:35:05 CET 2014


Patrick Snape schrieb am 15.10.2014 um 20:27:
> To reproduce:
> 
>     # distutils: language = c++
>     import numpy as np
>     cimport numpy as np
>     cimport cython
> 
> 
>     cdef test_np_int64(const np.int64_t test_var):
>         cdef np.int64_t error = test_var / 2
> 
> 
> This fails to compile with the error:
> 
>     In function ‘const __pyx_t_5numpy_int64_t
>   __Pyx_div___pyx_t_5numpy_int64_t__const__(__pyx_t_5numpy_int64_t,
> __pyx_t_5numpy_int64_t)’:
>     error: assignment of read-only variable ‘q’
>          q -= ((r != 0) & ((r ^ b) < 0));
> 
> 
> Using just a regular int type:
> 
>     # distutils: language = c++
>     import numpy as np
>     cimport numpy as np
>     cimport cython
> 
> 
>     cdef test_int(const int test_var):
>         cdef int no_error = test_var / 2
> 
> Works as expected.
> 
> Fixing this is as simple as removing the const that is being complained
> about. I assume this is a bug?

Yes, looks like a bug to me. Thanks for reporting it.

Stefan



More information about the cython-devel mailing list