QUERY · ISSUE
mp_obj_class_lookup error
After I rebuilt, there was a problem running the example. I don't know why
assertion "mp_obj_is_dict_or_ordereddict(MP_OBJ_FROM_PTR(type->locals_dict))" failed: file "/home/hxm/Desktop/lv_micropython/py/objtype.c", line 156, function: mp_obj_class_lookup
CANDIDATE · PULL REQUEST
py: Support passing in an OrderedDict to type() as the locals.
py-core
Split off frm #6130, this PR adds support for passing in an OrderedDict for the locals of a new class, using type(name, bases, locals), where locals can now be an OrderedDict.
The changes here introduce a new helper mp_obj_is_dict_or_ordereddict() and update existing code to use it (which decreases code size in extmod/moductypes.c). The actual feature of using OrderedDict as class locals costs 0 bytes.