Skip to content

Commit f235c28

Browse files
committed
py/modbuiltins: Keep class locals ordered as per their definition.
1 parent 27b7bf3 commit f235c28

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

py/modbuiltins.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args)
5252
// set the new classes __locals__ object
5353
mp_obj_dict_t *old_locals = mp_locals_get();
5454
mp_obj_t class_locals = mp_obj_new_dict(0);
55+
#if MICROPY_PY_CLASS_ORDERED_LOCALS
56+
// keep the locals ordered
57+
mp_obj_dict_t *dict = MP_OBJ_TO_PTR(class_locals);
58+
dict->map.is_ordered = 1;
59+
#endif
5560
mp_locals_set(MP_OBJ_TO_PTR(class_locals));
5661

5762
// call the class code

0 commit comments

Comments
 (0)