From 8fae7d2e3024de6336affc4b2a8fa992c946e017 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 May 2021 09:37:41 -0500 Subject: [PATCH] runtime.c: Fix reading properties .. this fixes the vfs_fat_ramdisk failure. --- py/runtime.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/py/runtime.c b/py/runtime.c index 740457c462..9791379d79 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1062,27 +1062,27 @@ void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t } dest[0] = ((mp_obj_static_class_method_t *)MP_OBJ_TO_PTR(member))->fun; dest[1] = MP_OBJ_FROM_PTR(type); + #if MICROPY_PY_BUILTINS_PROPERTY + // If self is MP_OBJ_NULL, we looking at the class itself, not an instance. + } else if (mp_obj_is_type(member, &mp_type_property) && mp_obj_is_native_type(type) && self != MP_OBJ_NULL) { + // object member is a property; delegate the load to the property + // Note: This is an optimisation for code size and execution time. + // The proper way to do it is have the functionality just below + // in a __get__ method of the property object, and then it would + // be called by the descriptor code down below. But that way + // requires overhead for the nested mp_call's and overhead for + // the code. + const mp_obj_t *proxy = mp_obj_property_get(member); + if (proxy[0] == mp_const_none) { + mp_raise_AttributeError(translate("unreadable attribute")); + } else { + dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self); + } + #endif } else { // `member` is a value, so just return that value. dest[0] = member; } - #if MICROPY_PY_BUILTINS_PROPERTY - // If self is MP_OBJ_NULL, we looking at the class itself, not an instance. - } else if (mp_obj_is_type(member, &mp_type_property) && mp_obj_is_native_type(type) && self != MP_OBJ_NULL) { - // object member is a property; delegate the load to the property - // Note: This is an optimisation for code size and execution time. - // The proper way to do it is have the functionality just below - // in a __get__ method of the property object, and then it would - // be called by the descriptor code down below. But that way - // requires overhead for the nested mp_call's and overhead for - // the code. - const mp_obj_t *proxy = mp_obj_property_get(member); - if (proxy[0] == mp_const_none) { - mp_raise_AttributeError(translate("unreadable attribute")); - } else { - dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self); - } - #endif } else { // `member` is a value, so just return that value. dest[0] = member;