Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
69d081a7
Commit
69d081a7
authored
May 25, 2014
by
Paul Sokolovsky
Browse files
py: Handle case of slice start > stop in common sequence function.
parent
afaaf535
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/objstr.c
View file @
69d081a7
...
...
@@ -355,9 +355,6 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if
(
!
mp_seq_get_fast_slice_indexes
(
self_len
,
index
,
&
start
,
&
stop
))
{
assert
(
0
);
}
if
(
start
>=
stop
)
{
return
MP_OBJ_NEW_QSTR
(
MP_QSTR_
);
}
return
str_new
(
type
,
self_data
+
start
,
stop
-
start
);
}
#endif
...
...
py/sequence.c
View file @
69d081a7
...
...
@@ -88,6 +88,12 @@ bool mp_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, machine_u
}
else
if
(
stop
>
len
)
{
stop
=
len
;
}
// CPython returns empty sequence in such case, or point for assignment is at start
if
(
start
>
stop
)
{
stop
=
start
;
}
*
begin
=
start
;
*
end
=
stop
;
return
true
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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