Reported by nikratio on 18 Sep 2015 19:11 UTC
Consider the following code:
from libc cimport stdio
def do_test():
cdef int i
cdef int vals[ callbacks = [](3]
)
for i in range(3):
vals[= i
def cb(void* i_=vals+i):
stdio.printf('%d\n', *<int*>i_)
callbacks.append(cb)
for cb in callbacks:
cb()
This cannot work, because Cython has to make cb callable from Python - but there is no good way to convert a Python object to void*.
However, Cython's error message is a bit misleading:
$ cython -3 -Wextra --force -3 --directive embedsignature=True mylib.pyx --fast-fail
Error compiling Cython file:
------------------------------------------------------------
...
cdef int vals[3](i])
callbacks = [ for i in range(3):
vals[i](]
) = i
def cb(void* i_=vals+i):
^
------------------------------------------------------------
mylib.pyx:10:8: Cannot convert 'void *' to Python object
Should this say Cannot convert Python object to 'void*' (i.e., the other way around)?
Reported by nikratio on 18 Sep 2015 19:11 UTC Consider the following code:
This cannot work, because Cython has to make
cb
callable from Python - but there is no good way to convert a Python object tovoid*
.However, Cython's error message is a bit misleading:
Should this say
Cannot convert Python object to 'void*'
(i.e., the other way around)?Migrated-From: http://trac.cython.org/ticket/867