Skip to content

Commit eea0118

Browse files
committed
py: Give up and make mp_obj_str_get_data() deal with bytes too.
This is not fully correct re: error handling, because we should check that that types are used consistently (only str's or only bytes), but magically makes lot of functions support bytes.
1 parent b2d4fc0 commit eea0118

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ const char *mp_obj_str_get_str(mp_obj_t self_in) {
16471647
}
16481648

16491649
const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len) {
1650-
if (MP_OBJ_IS_STR(self_in)) {
1650+
if (is_str_or_bytes(self_in)) {
16511651
GET_STR_DATA_LEN(self_in, s, l);
16521652
*len = l;
16531653
return (const char*)s;

tests/basics/int1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
print(int('0100', 2))
4747
print(int(' \t 0o12', 8))
4848
print(int('0o12 \t ', 8))
49+
print(int(b"12", 10))
4950

5051

5152
def test(value, base):

0 commit comments

Comments
 (0)