Skip to content

Commit 74457d8

Browse files
committed
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.
1 parent dc4e5cb commit 74457d8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
15561556
char ch = mp_obj_get_int(arg);
15571557
mp_print_strn(&print, &ch, 1, flags, ' ', width);
15581558
} else {
1559-
mp_raise_TypeError(MP_ERROR_TEXT("integer required"));
1559+
mp_raise_TypeError(MP_ERROR_TEXT("%%c requires int or char"));
15601560
}
15611561
break;
15621562

0 commit comments

Comments
 (0)