robertwb / issues-import-test

0 stars 0 forks source link

Type checking in method overriding broken for "ctypedef extern class" types #46

Closed robertwb closed 8 years ago

robertwb commented 8 years ago

Reported by dan on 19 Jun 2008 14:53 UTC 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 [PyArrayObject](object):

Here is what happens when you run:

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

Migrated-From: http://trac.cython.org/ticket/20

robertwb commented 8 years ago

Modified by robertwb on 19 Aug 2008 04:04 UTC

robertwb commented 8 years ago

Comment by robertwb on 8 Nov 2008 22:38 UTC This is because a .pxi file is being used rather than a .pxd file.

robertwb commented 8 years ago

Modified by robertwb on 8 Nov 2008 23:29 UTC