Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
c8d1384f
Commit
c8d1384f
authored
Jan 04, 2014
by
Damien George
Browse files
Fix int -> machine_int_t; add print to slice test.
parent
b95d90b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/objstr.c
View file @
c8d1384f
...
...
@@ -35,7 +35,7 @@ mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return
mp_obj_new_int
(
lhs_str
[
mp_obj_get_int
(
rhs_in
)]);
#if MICROPY_ENABLE_SLICE
}
else
if
(
MP_OBJ_IS_TYPE
(
rhs_in
,
&
slice_type
))
{
in
t
start
,
stop
,
step
;
machine_int_
t
start
,
stop
,
step
;
mp_obj_slice_get
(
rhs_in
,
&
start
,
&
stop
,
&
step
);
assert
(
step
==
1
);
int
len
=
strlen
(
lhs_str
);
...
...
tests/basics/tests/slice-bstr1.py
View file @
c8d1384f
b
"123"
[
0
:
1
]
print
(
b
"123"
[
0
:
1
]
)
b
"123"
[
0
:
2
]
print
(
b
"123"
[
0
:
2
]
)
b
"123"
[:
1
]
print
(
b
"123"
[:
1
]
)
b
"123"
[
1
:]
print
(
b
"123"
[
1
:]
)
# Idiom for copying sequence
b
"123"
[:]
print
(
b
"123"
[:]
)
b
"123"
[:
-
1
]
print
(
b
"123"
[:
-
1
]
)
# Weird cases
b
"123"
[
0
:
0
]
b
"123"
[
1
:
0
]
b
"123"
[
1
:
1
]
b
"123"
[
-
1
:
-
1
]
b
"123"
[
-
3
:]
b
"123"
[
-
3
:
3
]
b
"123"
[
0
:]
b
"123"
[:
0
]
b
"123"
[:
-
3
]
b
"123"
[:
-
4
]
print
(
b
"123"
[
0
:
0
]
)
print
(
b
"123"
[
1
:
0
]
)
print
(
b
"123"
[
1
:
1
]
)
print
(
b
"123"
[
-
1
:
-
1
]
)
print
(
b
"123"
[
-
3
:]
)
print
(
b
"123"
[
-
3
:
3
]
)
print
(
b
"123"
[
0
:]
)
print
(
b
"123"
[:
0
]
)
print
(
b
"123"
[:
-
3
]
)
print
(
b
"123"
[:
-
4
]
)
# No IndexError!
b
""
[
1
:
1
]
b
""
[
-
1
:
-
1
]
print
(
b
""
[
1
:
1
]
)
print
(
b
""
[
-
1
:
-
1
]
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment