Skip to content

Commit 31619cc

Browse files
committed
py: mp_obj_str_get_str(): Work with bytes too.
It should be fair to say that almost in all cases where some API call expects string, it should be also possible to pass byte string. For example, it should be open/delete/rename file with name as bytestring. Note that similar change was done quite a long ago to mp_obj_str_get_data().
1 parent 11aa916 commit 31619cc

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
@@ -1895,7 +1895,7 @@ qstr mp_obj_str_get_qstr(mp_obj_t self_in) {
18951895
// only use this function if you need the str data to be zero terminated
18961896
// at the moment all strings are zero terminated to help with C ASCIIZ compatibility
18971897
const char *mp_obj_str_get_str(mp_obj_t self_in) {
1898-
if (MP_OBJ_IS_STR(self_in)) {
1898+
if (MP_OBJ_IS_STR_OR_BYTES(self_in)) {
18991899
GET_STR_DATA_LEN(self_in, s, l);
19001900
(void)l; // len unused
19011901
return (const char*)s;

0 commit comments

Comments
 (0)