Commit def2732c authored by Jeroen Demeyer's avatar Jeroen Demeyer

Fix overriding of cdef by cpdef method in .pxd file

See https://github.com/cython/cython/issues/543
parent ebf960e4
......@@ -2055,7 +2055,6 @@ class CClassScope(ClassScope):
pass
elif type.compatible_signature_with(entry.type, as_cmethod = 1) and type.nogil == entry.type.nogil:
entry = self.add_cfunction(name, type, pos, cname, visibility='ignore', modifiers=modifiers)
defining = 1
else:
error(pos, "Signature not compatible with previous declaration")
error(entry.pos, "Previous declaration is here")
......
PYTHON setup.py build_ext --inplace
PYTHON test.py
######## setup.py ########
from Cython.Build import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize("*.pyx"),
)
######## test.py ########
from base import A, B
from derived import C
assert B().foo() == 'B.foo'
assert C().foo() == 'B.foo'
assert A().foo1() == 'A.foo'
assert B().foo1() == 'B.foo'
assert C().foo1() == 'B.foo'
assert B().foo2() == 'B.foo'
assert C().foo2() == 'B.foo'
assert C().bar() == 'C.bar'
######## base.pxd ########
cdef class A(object):
cdef foo(self)
cdef class B(A):
cpdef foo(self)
######## base.pyx ########
cdef class A(object):
cdef foo(self):
return "A.foo"
def foo1(self):
return self.foo()
cdef class B(A):
cpdef foo(self):
return "B.foo"
def foo2(self):
return self.foo()
######## derived.pyx ########
from base cimport B
cdef class C(B):
cpdef bar(self):
return "C.bar"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment