Fixes the following assertion failures when the arguments to type()
were not of valid types:
micropython: ../../py/objtype.c:984: mp_obj_new_type: Assertion `MP_OBJ_IS_TYPE(bases_tuple, &mp_type_tuple)' failed.
micropython: ../../py/objtype.c:994: mp_obj_new_type: Assertion `MP_OBJ_IS_TYPE(items[i], &mp_type_type)' failed.
e.g., when making calls like
type("", (), 3)
type("", 3, {})
20 lines
268 B
Python
20 lines
268 B
Python
try:
|
|
type('abc', None, None)
|
|
except TypeError:
|
|
print(True)
|
|
else:
|
|
print(False)
|
|
|
|
try:
|
|
type('abc', (), None)
|
|
except TypeError:
|
|
print(True)
|
|
else:
|
|
print(False)
|
|
|
|
try:
|
|
type('abc', (1,), {})
|
|
except TypeError:
|
|
print(True)
|
|
else:
|
|
print(False)
|