Skip to content

Commit

Permalink
Merge 2a076f4 into 9883d8e
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmo committed Aug 4, 2020
2 parents 9883d8e + 2a076f4 commit 992af47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions py/objtype.c
Expand Up @@ -1015,6 +1015,9 @@ STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
// Returns a read-only dict of the class attributes.
// If the internal locals is not fixed, a copy will be created.
mp_obj_dict_t *dict = self->locals_dict;
if (!dict) {
dict = MP_OBJ_TO_PTR(mp_obj_new_dict(0));
}
if (dict->map.is_fixed) {
dest[0] = MP_OBJ_FROM_PTR(dict);
} else {
Expand Down
5 changes: 5 additions & 0 deletions tests/basics/class_dict.py
Expand Up @@ -17,3 +17,8 @@ class Foo:

d = Foo.__dict__
print(d["a"], d["b"])


# dict of a class that has no locals_dict (return empty dict).
d = type(type('')).__dict__
print(d is not None)

0 comments on commit 992af47

Please sign in to comment.