[issue39960] Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is broken (hackcheck too eager?)
Stefan Behnel
report at bugs.python.org
Sun Jun 21 16:55:07 EDT 2020
Stefan Behnel <stefan_ml at behnel.de> added the comment:
This SO answer by Martijn Pieters explains the background:
https://stackoverflow.com/a/44854477
and links to the original python-dev discussion:
https://mail.python.org/pipermail/python-dev/2003-April/034535.html
The current implementation checks that the function being called is the one defined in the first non-heap type up the hierarchy. As long as heap types are only Python types, this is the first builtin/native/C-implemented (super)type. With extension types as heap types, however, it's no longer necessarily the type that defines the correct slot function.
IMHO, Greg Ewing gives the right direction here:
https://mail.python.org/pipermail/python-dev/2003-April/034569.html
> Providing some way for objects to prevent superclass
> methods from being called on them when they're not looking
So, I think we should do something like walking up the hierarchy to find the C function in it that is currently being called, and then check if it's the one we would expect or if a subclass defines a different one. The current check does not bother to search and just assumes that it knows which (super)type defines the right function to call.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39960>
_______________________________________
More information about the Python-bugs-list
mailing list