Skip to content

Commit dfeaea1

Browse files
committed
py/objtype: Remove TODO comment about needing to check for property.
Instance members are always treated as values, even if they are properties. A test is added to show this is the case.
1 parent 15ddc20 commit dfeaea1

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

py/objtype.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
562562
mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
563563
if (elem != NULL) {
564564
// object member, always treated as a value
565-
// TODO should we check for properties?
566565
dest[0] = elem->value;
567566
return;
568567
}

tests/basics/builtin_property.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,9 @@ class E:
105105
# not tested for because the other keyword arguments are not accepted
106106
# q = property(fget=lambda self: 21, doc="Half the truth.")
107107
print(E().p)
108+
109+
# a property as an instance member should not be delegated to
110+
class F:
111+
def __init__(self):
112+
self.prop_member = property()
113+
print(type(F().prop_member))

0 commit comments

Comments
 (0)