diff options
Diffstat (limited to 'py')
-rw-r--r-- | py/objstr.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/py/objstr.c b/py/objstr.c index d0dee04e5..a3f2d6075 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -789,9 +789,9 @@ mp_obj_t str_format(uint n_args, const mp_obj_t *args) { "Unknown format code '%c' for object of type '%s'", type, mp_obj_get_type_str(arg))); } } + // NOTE: no else here. We need the e, f, g etc formats for integer // arguments (from above if) to take this if. -#if MICROPY_ENABLE_FLOAT if (arg_looks_numeric(arg)) { if (!type) { @@ -830,6 +830,7 @@ mp_obj_t str_format(uint n_args, const mp_obj_t *args) { flags |= PF_FLAG_PAD_NAN_INF; // '{:06e}'.format(float('-inf')) should give '-00inf' switch (type) { +#if MICROPY_ENABLE_FLOAT case 'e': case 'E': case 'f': @@ -843,16 +844,14 @@ mp_obj_t str_format(uint n_args, const mp_obj_t *args) { flags |= PF_FLAG_ADD_PERCENT; pfenv_print_float(&pfenv_vstr, mp_obj_get_float(arg) * 100.0F, 'f', flags, fill, width, precision); break; +#endif default: nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Unknown format code '%c' for object of type 'float'", type, mp_obj_get_type_str(arg))); } - } else -#endif - - { + } else { // arg doesn't look like a number if (align == '=') { |