From d50f649cf8a10c98085f10ef476d43e902458e3c Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 20 Dec 2015 16:50:51 +0200 Subject: [PATCH] py/objstr: Applying % (format) operator to bytes should return bytes, not str. --- py/objstr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/objstr.c b/py/objstr.c index fbe61a26f1..7315f40020 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1484,7 +1484,7 @@ not_enough_args: nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "not all arguments converted during string formatting")); } - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr); } // The implementation is optimized, returning the original string if there's