diff options
author | Damien George <damien.p.george@gmail.com> | 2015-12-09 17:30:01 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-12-09 17:30:01 +0000 |
commit | 3ff259a262a6619325211909bbf3781538232b6f (patch) | |
tree | d87d2a2d6af086b098872806783123fd463aa7f1 /py | |
parent | 1be0fde45c8d84eaf04851af96f06aad8171b2b2 (diff) |
py: Fix calling of parent classmethod from instance of subclass.
Addresses issue #1697.
Diffstat (limited to 'py')
-rw-r--r-- | py/runtime.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c index c6a85bb01..58b5a5dd1 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -934,6 +934,11 @@ 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; } else if (MP_OBJ_IS_TYPE(member, &mp_type_classmethod)) { // return a bound method, with self being the type of this object + // this type should be the type of the original instance, not the base + // type (which is what is passed in the 'type' argument to this function) + if (self != MP_OBJ_NULL) { + type = mp_obj_get_type(self); + } dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun; dest[1] = MP_OBJ_FROM_PTR(type); } else if (MP_OBJ_IS_TYPE(member, &mp_type_type)) { |