Skip to content

Commit d50f649

Browse files
committed
py/objstr: Applying % (format) operator to bytes should return bytes, not str.
1 parent ef63ab5 commit d50f649

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
14841484
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "not all arguments converted during string formatting"));
14851485
}
14861486

1487-
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
1487+
return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr);
14881488
}
14891489

14901490
// The implementation is optimized, returning the original string if there's

0 commit comments

Comments
 (0)