QUERY · ISSUE
Descriptor attribute access on a class doesn't call __get__
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 · ISSUE
classmethod fetches parent attribute instead of child attribute when called via child object
CPython 2 and 3 print 1 for the following code, however MicroPython prints 0
class A(object):
foo = 0
@classmethod
def bar(cls):
print(cls.foo)
class B(A):
foo = 1
B().bar()
I use this to have a generic base class with generic data structures that can be extended by derived classes. The generic classmethod is supposed to use the extended data, if it was called via the derived object.
The actual code doing this is here (generic) https://github.com/mbuesch/awlsim/blob/master/awlsim/core/hardware.py and here (derived) https://github.com/mbuesch/awlsim/blob/master/awlsimhw_debug/main.py
Is there a workaround to this issue?