@@ -121,7 +121,7 @@ STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
121121 #else
122122 bool is_bytes = true;
123123 #endif
124- if (!MICROPY_PY_BUILTINS_STR_UNICODE && kind == PRINT_STR && !is_bytes ) {
124+ if (kind == PRINT_RAW || ( !MICROPY_PY_BUILTINS_STR_UNICODE && kind == PRINT_STR && !is_bytes ) ) {
125125 mp_printf (print , "%.*s" , str_len , str_data );
126126 } else {
127127 if (is_bytes ) {
@@ -1296,6 +1296,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
12961296
12971297 GET_STR_DATA_LEN (pattern , str , len );
12981298 const byte * start_str = str ;
1299+ bool is_bytes = MP_OBJ_IS_TYPE (pattern , & mp_type_bytes );
12991300 int arg_i = 0 ;
13001301 vstr_t vstr ;
13011302 mp_print_t print ;
@@ -1444,7 +1445,13 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
14441445 vstr_t arg_vstr ;
14451446 mp_print_t arg_print ;
14461447 vstr_init_print (& arg_vstr , 16 , & arg_print );
1447- mp_obj_print_helper (& arg_print , arg , * str == 'r' ? PRINT_REPR : PRINT_STR );
1448+ mp_print_kind_t print_kind = (* str == 'r' ? PRINT_REPR : PRINT_STR );
1449+ if (print_kind == PRINT_STR && is_bytes && MP_OBJ_IS_TYPE (arg , & mp_type_bytes )) {
1450+ // If we have something like b"%s" % b"1", bytes arg should be
1451+ // printed undecorated.
1452+ print_kind = PRINT_RAW ;
1453+ }
1454+ mp_obj_print_helper (& arg_print , arg , print_kind );
14481455 uint vlen = arg_vstr .len ;
14491456 if (prec < 0 ) {
14501457 prec = vlen ;
0 commit comments