aboutsummaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2018-09-21 16:44:04 -0700
committerDamien George <damien.p.george@gmail.com>2018-09-26 15:29:41 +1000
commita135bca4a10b99e80a2732cff1a53c6a4734c145 (patch)
tree8993e4bf12dcc9b158e0fe3c0a30d69b4b24977b /py/objstr.c
parent09c5c58a1f797f3eeaf5088b7d6ef92d86c26532 (diff)
py/objstr: format: Return bytes result for bytes format string.
This is an improvement over previous behavior when str was returned for both str and bytes input format. This new behaviour is also consistent with how the % operator works, as well as many other str/bytes methods. It should be noted that it's not how current versions of CPython work, where there's a gap in the functionality and bytes.format() is not supported.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objstr.c b/py/objstr.c
index f9dcb28c5..e519a9879 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -1387,7 +1387,7 @@ mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
GET_STR_DATA_LEN(args[0], str, len);
int arg_i = 0;
vstr_t vstr = mp_obj_str_format_helper((const char*)str, (const char*)str + len, &arg_i, n_args, args, kwargs);
- return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
+ return mp_obj_new_str_from_vstr(mp_obj_get_type(args[0]), &vstr);
}
MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format);