Ticket #20 (closed defect: invalid)
Type checking in method overriding broken for "ctypedef extern class" types
| Reported by: | dan | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | 0.10 |
| Component: | Parsing | Keywords: | |
| Cc: |
Description
It seems if you have a method in a class with an argument typed to be an "ndarray":
cdef class base:
cdef void func(self, ndarray arr): pass
and you then try to override the method in a derived class, you get errors. Things work fine if the type of the argument is an "int", or if both base and derived class are in the same file.
I think this happens because "ndarray" is not a cdef class kind of a type, but comes in from an outside library -- numpy -- as a:
ctypedef extern class numpy.ndarray [object PyArrayObject?]:
Here is what happens when you run:
+ python cython.py base.pyx
+ gcc -c -fPIC -O6 -fno-strict-aliasing -I/usr/include/python2.3 base.c
+ gcc -shared -lm base.o -o base.so
+ python cython.py main.pyx
Error converting Pyrex file to C: ------------------------------------------------------------ ... cdef class item(base.base): #cdef void method(me, int arr): pass cdef void method(me, ndarray arr): pass ^ ------------------------------------------------------------ /home/dg/w/pex/Tickets/01_ndarray_as_overridden_arg/main.pyx:8:6: Signature not compatible with previous declaration Error converting Pyrex file to C: ------------------------------------------------------------ ... include "numpy.pxi" cdef class base: #cdef void method(me, int arr) cdef void method(me, ndarray arr) ^ ------------------------------------------------------------ /home/dg/w/pex/Tickets/01_ndarray_as_overridden_arg/base.pxd:7:17: Previous declaration is here

