diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-15 22:45:20 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-16 03:46:01 +0200 |
commit | f2b796e7c76e43b10258b6a87bd84884fa879984 (patch) | |
tree | dfedcd2c86e0566b9bde4df9ad38fa17d4cdbd93 /py/objstr.c | |
parent | b99d9ea25830b4b2e384c180012ee0ddc23f1316 (diff) | |
download | micropython-f2b796e7c76e43b10258b6a87bd84884fa879984.tar.gz micropython-f2b796e7c76e43b10258b6a87bd84884fa879984.zip |
str.format: Don't assume that '}' immediately follows '{', skip insides.
That at least makes stuff like "{:x}".format(1) to produce not completely
broken output.
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/objstr.c b/py/objstr.c index 0621a8df75..7c1be50cc0 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -270,7 +270,8 @@ mp_obj_t str_format(int n_args, const mp_obj_t *args) { str++; if (*str == '{') { vstr_add_char(vstr, '{'); - } else if (*str == '}') { + } else { + while (*str != '}') str++; if (arg_i >= n_args) { nlr_jump(mp_obj_new_exception_msg(MP_QSTR_IndexError, "tuple index out of range")); } |