Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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:


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 base.pyx

+ gcc -c -fPIC -O6 -fno-strict-aliasing -I/usr/include/python2.3 base.c

+ gcc -shared -lm base.o -o

+ python 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

Attachments (1) (2.7 KB) - added by anonymous 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by anonymous

comment:1 Changed 7 years ago by robertwb

  • Milestone set to

comment:2 Changed 7 years ago by robertwb

  • Resolution set to invalid
  • Status changed from new to closed

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

comment:3 Changed 7 years ago by robertwb

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