← index #5669PR #15940
Related · high · value 2.637
QUERY · ISSUE

Descriptor attribute access on a class doesn't call __get__

openby tannewtopened 2020-02-19updated 2020-02-20
py-core

CPython calls __get__ with obj as None when a descriptor is accessed on the class itself rather than an instance. MicroPython returns the descriptor instance instead of calling __get__.

CANDIDATE · PULL REQUEST

py/objtype: Don't delegate lookup of descriptor methods to __getattr__.

mergedby dpgeorgeopened 2024-10-01updated 2024-10-16
py-core

Summary

When descriptors are enabled, lookup of the __get__, __set__ and __delete__ descriptor methods should not be delegated to __getattr__. That follows CPython behaviour.

Issue initially found by @ntoll.

Testing

Added a test for these cases.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied