Fix str.modulo when precision is specified.

This commit is contained in:
Dave Hylands
2014-06-05 23:09:02 -07:00
parent 380f147d2e
commit b69f9fa31f
4 changed files with 73 additions and 13 deletions

View File

@@ -981,7 +981,7 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) {
if (arg_looks_integer(arg)) {
switch (type) {
case 'b':
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 2, 'a', flags, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 2, 'a', flags, fill, width, 0);
continue;
case 'c':
@@ -994,7 +994,7 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) {
case '\0': // No explicit format type implies 'd'
case 'n': // I don't think we support locales in uPy so use 'd'
case 'd':
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 10, 'a', flags, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 10, 'a', flags, fill, width, 0);
continue;
case 'o':
@@ -1002,12 +1002,12 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) {
flags |= PF_FLAG_SHOW_OCTAL_LETTER;
}
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 8, 'a', flags, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 8, 'a', flags, fill, width, 0);
continue;
case 'X':
case 'x':
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 16, type - ('X' - 'A'), flags, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 16, type - ('X' - 'A'), flags, fill, width, 0);
continue;
case 'e':
@@ -1255,7 +1255,7 @@ not_enough_args:
case 'd':
case 'i':
case 'u':
pfenv_print_mp_int(&pfenv_vstr, arg_as_int(arg), 1, 10, 'a', flags, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg_as_int(arg), 1, 10, 'a', flags, fill, width, prec);
break;
#if MICROPY_PY_BUILTINS_FLOAT
@@ -1273,7 +1273,7 @@ not_enough_args:
if (alt) {
flags |= (PF_FLAG_SHOW_PREFIX | PF_FLAG_SHOW_OCTAL_LETTER);
}
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 8, 'a', flags, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 8, 'a', flags, fill, width, prec);
break;
case 'r':
@@ -1296,7 +1296,7 @@ not_enough_args:
case 'X':
case 'x':
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 16, *str - ('X' - 'A'), flags | alt, fill, width);
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec);
break;
default: