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.
This commit is contained in:
Paul Sokolovsky
2014-01-15 22:45:20 +02:00
parent b99d9ea258
commit f2b796e7c7
2 changed files with 10 additions and 1 deletions

View File

@@ -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"));
}