[Cython] Problem with final cdef methods

Nikita Nemkin nikita at nemkin.ru
Thu Aug 29 09:19:34 CEST 2013


On Thu, 29 Aug 2013 12:57:19 +0600, Stefan Behnel <stefan_ml at behnel.de>  
wrote:

> Nikita Nemkin, 29.08.2013 08:24:
>> I have solved it for myself by storing BOTH types in the method entry
>> (Entry.type for the actual CFuncDef type and Entry.prev_type for the  
>> vtable
>> slot type). By using correct types in
>> generate_exttype_final_methods_declaration()
>> and generate_exttype_vtable_init_code() the problem is avoided.
>> You can see the patch here
>> https://github.com/nnemkin/cython/compare/final_subtypes
>
> Interesting. Your change dates back a while already. Were you planning to
> clean it up in some way before you submit it as pull request?

That was the plan.
My solution is kind of stopgap (even the name "prev_type" makes me cringe),
but "proper" solution would require some serious redesign and rewrite work,
which may be unwise in itsef. So I got stuck and left it behind.

If you want the problem fixed with minimal changes to the Cython
codebase, you can use my approach.

BTW I havent thoroughly tested that patch. It works for me
in my environment and passes the test suite, but that's it.

>> Notes for the patch:
>> * There is a disabled bug test named "inherited_final_method",
>
> And you had to disable it, because ... ?
>
>> you may want to remove/merge it with the test you modified.
>
> I already looked at it before I changed the main test. It appears to be a
> regression test for a specific bug that's different from the problem at
> hand, that's why I didn't touch it.

The test was already disabled, because it hit the open bug.
It's the same bug we are talking about: mismatch between Entry.type and
the actual method type. Please take a closer look at it.
My patch ENABLES the test because it fixes the bug.


Best regards,
Nikita Nemkin


More information about the cython-devel mailing list