Skip to content

Commit 803a4d7

Browse files
jeplerdpgeorge
authored andcommitted
py/objtemplate: Correctly cast qstr literals when printing.
qstr literals are of type qstr_short_t (aka uint16_t) for efficiency, but when the type is passed to `mp_printf` it must be cast explicitly to type `qstr`. These locations were found using an experimental gcc plugin for `mp_printf` error checking. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
1 parent 702f15a commit 803a4d7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

py/objtemplate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ static mp_obj_t mp_obj_template_make_new(const mp_obj_type_t *type, size_t n_arg
152152
static void mp_obj_template_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
153153
(void)kind;
154154
mp_obj_template_t *self = MP_OBJ_TO_PTR(self_in);
155-
mp_printf(print, "%q(%q=", MP_QSTR_Template, MP_QSTR_strings);
155+
mp_printf(print, "%q(%q=", (qstr)MP_QSTR_Template, (qstr)MP_QSTR_strings);
156156
mp_obj_print_helper(print, self->strings, PRINT_REPR);
157-
mp_printf(print, ", %q=", MP_QSTR_interpolations);
157+
mp_printf(print, ", %q=", (qstr)MP_QSTR_interpolations);
158158
mp_obj_print_helper(print, self->interpolations, PRINT_REPR);
159159
mp_print_str(print, ")");
160160
}
@@ -346,7 +346,7 @@ static mp_obj_t mp_obj_interpolation_make_new(const mp_obj_type_t *type, size_t
346346
static void mp_obj_interpolation_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
347347
(void)kind;
348348
mp_obj_interpolation_t *self = MP_OBJ_TO_PTR(self_in);
349-
mp_printf(print, "%q(", MP_QSTR_Interpolation);
349+
mp_printf(print, "%q(", (qstr)MP_QSTR_Interpolation);
350350
mp_obj_print_helper(print, self->value, PRINT_REPR);
351351
mp_print_str(print, ", ");
352352
mp_obj_print_helper(print, self->expression, PRINT_REPR);

0 commit comments

Comments
 (0)