Message 193232 - Python tracker (original) (raw)
issue-18181-full-v1.txt implements support for locallookup to both super and _PyType_Lookup and should implement the entire PEP.
The patch is not yet 100% and is missing:
Tests that add locallookup to a metaclass at runtime, should enable the new behavior
Tests that use the tp_locallookup slot in an type defined in C code
Documentation has not been updated.
Changes to the implementation:
_PyType_Lookup is now _PyType_LookupName and returns a new reference (not a borrowed one)
_PyType_Lookup and super.getattribute use the locallookup method when present
locallookup is not defined on "type", and the type attribute lookup cache is disabled for types that have a metatype with locallookup
The type attribute cache is disabled for types that are not ready (Py_TPFLAGS_READY), primarily as a side effect of the implementation.
The cache is also disabled for types with a metaclass that has a tp_locallookup attribute, as mentioned in the PEP.
The code does not change the VERSION flags of the type because dynamicly adding a locallookup method to the metaclass would have to change all instances of that metaclass and that's not easily possible.