Overridden method in final classes

7 views
Skip to first unread message

John Ehresman

unread,
May 24, 2025, 11:19:37 AMMay 24
to cython...@googlegroups.com
I can’t seem to override a method from a base class in a final derived class. For example —

The .pxd file:

import cython

cdef class Base:
cdef Virtual(self)

@cython.final
cdef class Derived(Base):
cdef Virtual(self)

The .py file:

class Base:
def Virtual(self):
return 1

class Derived(Base):
def Virtual(self):
return 2

The error I get when cythonizing is: Overriding final methods is not allowed and the line for the error is the def Virtual() in the Derived class. But, at least the way I think of it, I’m implementing the Virtual() method, not overriding it.

Is this a bug or due to some limitation that I’m not seeing?

Thanks,

John

da-woods

unread,
Jun 8, 2025, 3:00:34 AMJun 8
to cython...@googlegroups.com
Hi John - that definitely sounds like a bug. (Sorry for the slow reply)
Reply all
Reply to author
Forward
0 new messages