Merge branch 'master' of github.com:micropython/micropython
This commit is contained in:
commit
90886807a1
@ -47,8 +47,24 @@ STATIC mp_obj_t object_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MICROPY_CPYTHON_COMPAT
|
||||||
|
STATIC mp_obj_t object___init__(uint n_args, const mp_obj_t *args) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
STATIC const mp_map_elem_t object_locals_dict_table[] = {
|
||||||
|
#if MICROPY_CPYTHON_COMPAT
|
||||||
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___init__), (mp_obj_t)&object___init___obj },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
|
||||||
|
|
||||||
const mp_obj_type_t mp_type_object = {
|
const mp_obj_type_t mp_type_object = {
|
||||||
{ &mp_type_type },
|
{ &mp_type_type },
|
||||||
.name = MP_QSTR_object,
|
.name = MP_QSTR_object,
|
||||||
.make_new = object_make_new,
|
.make_new = object_make_new,
|
||||||
|
.locals_dict = (mp_obj_t)&object_locals_dict,
|
||||||
};
|
};
|
||||||
|
@ -735,8 +735,12 @@ STATIC void super_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
|||||||
for (uint i = 0; i < len; i++) {
|
for (uint i = 0; i < len; i++) {
|
||||||
assert(MP_OBJ_IS_TYPE(items[i], &mp_type_type));
|
assert(MP_OBJ_IS_TYPE(items[i], &mp_type_type));
|
||||||
mp_obj_class_lookup(self->obj, (mp_obj_type_t*)items[i], attr, 0, dest);
|
mp_obj_class_lookup(self->obj, (mp_obj_type_t*)items[i], attr, 0, dest);
|
||||||
|
if (dest[0] != MP_OBJ_NULL) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mp_obj_class_lookup(self->obj, &mp_type_object, attr, 0, dest);
|
||||||
|
}
|
||||||
|
|
||||||
const mp_obj_type_t mp_type_super = {
|
const mp_obj_type_t mp_type_super = {
|
||||||
{ &mp_type_type },
|
{ &mp_type_type },
|
||||||
|
15
tests/basics/class_super_object.py
Normal file
15
tests/basics/class_super_object.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Calling object.__init__() via super().__init__
|
||||||
|
|
||||||
|
class Test(object):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
print("Test.__init__")
|
||||||
|
|
||||||
|
t = Test()
|
||||||
|
|
||||||
|
class Test2:
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
print("Test2.__init__")
|
||||||
|
|
||||||
|
t = Test2()
|
Loading…
x
Reference in New Issue
Block a user