diff options
author | Damien George <damien.p.george@gmail.com> | 2015-08-26 15:42:25 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-08-29 23:13:51 +0100 |
commit | 7ef75f9f750da6f1a7f149bc6cd8c28f1d9cad50 (patch) | |
tree | b60325c82dd63021485f5d95632a4530fab4ce94 /py/objstr.c | |
parent | 51b9a0d0c4dfa265739708016ad85513d330987f (diff) | |
download | micropython-7ef75f9f750da6f1a7f149bc6cd8c28f1d9cad50.tar.gz micropython-7ef75f9f750da6f1a7f149bc6cd8c28f1d9cad50.zip |
py/objstr: Fix error type for badly formatted format specifier.
Was KeyError, should be ValueError.
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/py/objstr.c b/py/objstr.c index b51636a6ca..98360d9e11 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1065,7 +1065,12 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwa type = *s++; } if (*s) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_KeyError, "Invalid conversion specification")); + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, + "invalid format specifier")); + } } vstr_free(format_spec); format_spec = NULL; |