Ticket #20 (closed defect: invalid)

Opened 6 years ago

Last modified 5 years ago

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:


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


files.zip Download (2.7 KB) - added by anonymous 6 years ago.

Change History

Changed 6 years ago by anonymous

Changed 6 years ago by robertwb

  • milestone set to

Changed 5 years ago by robertwb

  • status changed from new to closed
  • resolution set to invalid

This is because a .pxi file is being used rather than a .pxd file.

Changed 5 years ago by robertwb

  • component changed from Code Generation to Parsing
Note: See TracTickets for help on using tickets.