py/objstr: Fix error reporting for unexpected end of modulo format str.

pull/1444/head
Damien George 2015-08-26 15:45:06 +01:00
rodzic 7ef75f9f75
commit b648e98ad0
2 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -1299,7 +1299,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
continue;
}
if (++str >= top) {
break;
goto incomplete_format;
}
if (*str == '%') {
vstr_add_byte(&vstr, '%');
@ -1369,6 +1369,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
}
if (str >= top) {
incomplete_format:
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {

Wyświetl plik

@ -111,3 +111,8 @@ try:
'%l' % 1
except ValueError:
print('ValueError')
try:
'a%' % 1
except ValueError:
print('ValueError')