str_modulo_format: Make error better match standard python

Before this, "%c" % 3.14 would raise the error `integer required`
even though python3 uses `%c requires int or char`, just like both
already did for "%c" % "ab".

This gets rid of a string to translate, and makes behavior match
python3 better.
This commit is contained in:
Jeff Epler 2021-10-16 19:37:12 -05:00
parent dc4e5cb33b
commit 74457d81f2
1 changed files with 1 additions and 1 deletions

View File

@ -1556,7 +1556,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
char ch = mp_obj_get_int(arg);
mp_print_strn(&print, &ch, 1, flags, ' ', width);
} else {
mp_raise_TypeError(MP_ERROR_TEXT("integer required"));
mp_raise_TypeError(MP_ERROR_TEXT("%%c requires int or char"));
}
break;