Skip to content

Commit 40f0096

Browse files
committed
Revert "py/objstr: .format(): Avoid call to vstr_null_terminated_str()."
This reverts commit 6de8dbb. The change was incorrect (correct change would require comparing with end pointer in each if statement in the block).
1 parent a1f2245 commit 40f0096

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

py/objstr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
10431043
// recursively call the formatter to format any nested specifiers
10441044
MP_STACK_CHECK();
10451045
vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs);
1046-
const char *s = format_spec_vstr.buf;
1046+
const char *s = vstr_null_terminated_str(&format_spec_vstr);
10471047
const char *stop = s + format_spec_vstr.len;
10481048
if (isalignment(*s)) {
10491049
align = *s++;
@@ -1083,7 +1083,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
10831083
if (istype(*s)) {
10841084
type = *s++;
10851085
}
1086-
if (s != stop) {
1086+
if (*s) {
10871087
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
10881088
terse_str_format_value_error();
10891089
} else {

0 commit comments

Comments
 (0)