Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpdef override of a cdef method can produce incorrect vtables #1732

Closed
saraedum opened this issue Jun 13, 2017 · 2 comments
Closed

cpdef override of a cdef method can produce incorrect vtables #1732

saraedum opened this issue Jun 13, 2017 · 2 comments
Milestone

Comments

@saraedum
Copy link
Contributor

saraedum commented Jun 13, 2017

There seems to be a problem in the way that cython checks for declarations of cpdef overrides of cdef methods. It seems that this is related to the feature introduced in #545.

Consider the following base.pxd, base.pyx, and bug.pyx:

cdef class A:
    cdef a(self)

cdef class B(A):
    pass
    #cpdef a(self)

cdef class C(B):
    cdef c(self)
cdef class A:
    cdef a(self):
        return "A.a()"

cdef class B(A):
    cpdef a(self):
        return "B.a()"

cdef class C(B):
    cdef c(self):
        return "C.c()"
from base cimport C

def call():
    return C().c()

Calling bug.call() prints B.a(). Enabling the #cpdef a(self) fixes the problem, and it prints C.c() as expected.

The problem here is that without the cpdef, the vtable used by bug.pyx is missing the entry for B.a.

To solve this problem, one would probably just have to add a check to Cython so it requires cpdef overrides of cdef methods to be declared in their .pxd files.

@robertwb robertwb added this to the 0.26 milestone Jun 14, 2017
@robertwb
Copy link
Contributor

Thanks for the report and concise repro.

@roed314
Copy link

roed314 commented Jun 15, 2017

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants