diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2020-06-10 10:45:24 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-06-10 21:58:13 +1000 |
commit | 28370c04509a6255cd3d6b9424443a5b57bb7467 (patch) | |
tree | 98d1f78a1805d14b85a88e54c910e0cf46168598 /py/objdict.c | |
parent | 29e258611ace8e4de51d810d5ff14364a5fbb950 (diff) |
py/objtype: Add __dict__ attribute for class objects.
The behavior mirrors the instance object dict attribute where a copy of the
local attributes are provided (unless the dict is read-only, then that dict
itself is returned, as an optimisation). MicroPython does not support
modifying this dict because the changes will not be reflected in the class.
The feature is only enabled if MICROPY_CPYTHON_COMPAT is set, the same as
the instance version.
Diffstat (limited to 'py/objdict.c')
-rw-r--r-- | py/objdict.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objdict.c b/py/objdict.c index 7690eeab2..69eda9973 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -227,7 +227,7 @@ STATIC mp_obj_t dict_clear(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear); -STATIC mp_obj_t dict_copy(mp_obj_t self_in) { +mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) { mp_check_self(mp_obj_is_dict_type(self_in)); mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t other_out = mp_obj_new_dict(self->map.alloc); @@ -240,7 +240,7 @@ STATIC mp_obj_t dict_copy(mp_obj_t self_in) { memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t)); return other_out; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, dict_copy); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy); #if MICROPY_PY_BUILTINS_DICT_FROMKEYS // this is a classmethod |