Skip to content

Commit c8d1384

Browse files
committed
Fix int -> machine_int_t; add print to slice test.
1 parent b95d90b commit c8d1384

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
3535
return mp_obj_new_int(lhs_str[mp_obj_get_int(rhs_in)]);
3636
#if MICROPY_ENABLE_SLICE
3737
} else if (MP_OBJ_IS_TYPE(rhs_in, &slice_type)) {
38-
int start, stop, step;
38+
machine_int_t start, stop, step;
3939
mp_obj_slice_get(rhs_in, &start, &stop, &step);
4040
assert(step == 1);
4141
int len = strlen(lhs_str);

tests/basics/tests/slice-bstr1.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
b"123"[0:1]
1+
print(b"123"[0:1])
22

3-
b"123"[0:2]
3+
print(b"123"[0:2])
44

5-
b"123"[:1]
5+
print(b"123"[:1])
66

7-
b"123"[1:]
7+
print(b"123"[1:])
88

99
# Idiom for copying sequence
10-
b"123"[:]
10+
print(b"123"[:])
1111

12-
b"123"[:-1]
12+
print(b"123"[:-1])
1313

1414
# Weird cases
15-
b"123"[0:0]
16-
b"123"[1:0]
17-
b"123"[1:1]
18-
b"123"[-1:-1]
19-
b"123"[-3:]
20-
b"123"[-3:3]
21-
b"123"[0:]
22-
b"123"[:0]
23-
b"123"[:-3]
24-
b"123"[:-4]
15+
print(b"123"[0:0])
16+
print(b"123"[1:0])
17+
print(b"123"[1:1])
18+
print(b"123"[-1:-1])
19+
print(b"123"[-3:])
20+
print(b"123"[-3:3])
21+
print(b"123"[0:])
22+
print(b"123"[:0])
23+
print(b"123"[:-3])
24+
print(b"123"[:-4])
2525
# No IndexError!
26-
b""[1:1]
27-
b""[-1:-1]
26+
print(b""[1:1])
27+
print(b""[-1:-1])

0 commit comments

Comments
 (0)