[Cython] Cannot coerce list to type 'list'
Robert Bradshaw
robertwb at math.washington.edu
Thu Dec 18 01:05:11 CET 2008
On Dec 17, 2008, at 3:54 PM, Muhammad Alkarouri wrote:
> Hi everyone,
>
> I have code that used to work in Cython 0.9.8.1.1 but doesn't work in
> the current version (0.10.3).
>
> I would like to know if this is a bug or is it something wrong in my
> code, and how to correct it either way. Can you please help me? The
> code and error are:
>
> from c_numpy cimport import_array, ndarray
> from c_python cimport list
> ...
> cdef class Scope:
> """A multidimensional interval"""
> cdef readonly ndarray centre
> cdef Scope parent
> cdef int height
> cdef list refinements
> def __init__(self, ndarray centre, Scope parent, int height):
> self.centre = centre
> self.parent = parent
> self.height = height
> self.refinements = []
> ^
> Cannot coerce list to type 'list'
Hmm... looks like the c_python declaration of "list" is conflicting
with the builtin list type which Cython now understands. Could you
try with Cython 0.10.2? For now you can do self.refinements = <list>[]
What is the definition of list in c_python? If it's a cdef extern
class of the actual python list, then this is a bug and should work.
Also, you might not need c_python anymore.
- Robert
More information about the Cython-dev
mailing list