[Cython] Simple class hierarchy problems

Brian Granger ellisonbg.net at gmail.com
Wed Jul 23 23:26:39 CEST 2008


Hi,

The following code is giving me problems:

# foo.pyx
cdef class Foo:

    cdef fooit(self):
        return 10

cdef class Bar(Foo):
    pass

cdef class Bam(Bar):
    pass

When I do "cython foo.pyx" and compile as c I get a warning:

foo.c: In function '__pyx_tp_new_3foo_Bam':
foo.c:608: warning: assignment from incompatible pointer type

But, when I do "cython --cplus" and compile with c++ I get a failure:

foo.cpp: In function 'PyObject* __pyx_tp_new_3foo_Bam(PyTypeObject*,
PyObject*, PyObject*)':
foo.cpp:608: error: cannot convert '__pyx_vtabstruct_3foo_Bar*' to
'__pyx_vtabstruct_3foo_Foo*' in a

I swear this code used to work fine.  I am using Cython 0.9.8, but the
problem is there if I try it in earlier versions.

What am I missing?

Thanks

Brian


More information about the Cython-dev mailing list