Change mp_obj_type_t.name from const char * to qstr.
Ultimately all static strings should be qstr. This entry in the type
structure is only used for printing error messages (to tell the type of
the bad argument), and printing objects that don't supply a .print method.
diff --git a/py/obj.c b/py/obj.c
index 4e0184a..86c0edc 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -26,7 +26,7 @@
}
const char *mp_obj_get_type_str(mp_obj_t o_in) {
- return mp_obj_get_type(o_in)->name;
+ return qstr_str(mp_obj_get_type(o_in)->name);
}
void printf_wrapper(void *env, const char *fmt, ...) {
@@ -41,7 +41,7 @@
if (type->print != NULL) {
type->print(print, env, o_in, kind);
} else {
- print(env, "<%s>", type->name);
+ print(env, "<%s>", qstr_str(type->name));
}
}
@@ -226,11 +226,11 @@
i += len;
}
if (i < 0 || i >= len) {
- nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_IndexError, "%s index out of range", type->name));
+ nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_IndexError, "%s index out of range", qstr_str(type->name)));
}
return i;
} else {
- nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "%s indices must be integers, not %s", type->name, mp_obj_get_type_str(index)));
+ nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "%s indices must be integers, not %s", qstr_str(type->name), mp_obj_get_type_str(index)));
}
}