kopia lustrzana https://github.com/micropython/micropython
py/objstr: Fix error reporting for unexpected end of modulo format str.
rodzic
7ef75f9f75
commit
b648e98ad0
|
@ -1299,7 +1299,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (++str >= top) {
|
if (++str >= top) {
|
||||||
break;
|
goto incomplete_format;
|
||||||
}
|
}
|
||||||
if (*str == '%') {
|
if (*str == '%') {
|
||||||
vstr_add_byte(&vstr, '%');
|
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) {
|
if (str >= top) {
|
||||||
|
incomplete_format:
|
||||||
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
|
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
|
||||||
terse_str_format_value_error();
|
terse_str_format_value_error();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -111,3 +111,8 @@ try:
|
||||||
'%l' % 1
|
'%l' % 1
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print('ValueError')
|
print('ValueError')
|
||||||
|
|
||||||
|
try:
|
||||||
|
'a%' % 1
|
||||||
|
except ValueError:
|
||||||
|
print('ValueError')
|
||||||
|
|
Ładowanie…
Reference in New Issue