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
c553162e
Commit
c553162e
authored
Jan 05, 2014
by
John R. Lenton
Browse files
Fix off-by-one in non-default values of index's 2nd and 3rd arguments.
parent
12e26564
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objlist.c
View file @
c553162e
...
...
@@ -182,13 +182,17 @@ static mp_obj_t list_index(int n_args, const mp_obj_t *args) {
assert
(
MP_OBJ_IS_TYPE
(
args
[
0
],
&
list_type
));
mp_obj_list_t
*
self
=
args
[
0
];
mp_obj_t
*
value
=
args
[
1
];
uint
start
=
0
;
uint
stop
=
self
->
len
;
uint
start
=
mp_get_index
(
self
->
base
.
type
,
self
->
len
,
n_args
>=
3
?
args
[
2
]
:
mp_obj_new_int
(
0
));
uint
stop
=
mp_get_index
(
self
->
base
.
type
,
self
->
len
,
n_args
>=
4
?
args
[
3
]
:
mp_obj_new_int
(
-
1
));
if
(
n_args
>=
3
)
{
start
=
mp_get_index
(
self
->
base
.
type
,
self
->
len
,
args
[
2
]);
if
(
n_args
>=
4
)
{
stop
=
mp_get_index
(
self
->
base
.
type
,
self
->
len
,
args
[
3
]);
}
}
for
(
uint
i
=
start
;
i
<
=
stop
;
i
++
)
{
for
(
uint
i
=
start
;
i
<
stop
;
i
++
)
{
if
(
mp_obj_equal
(
self
->
items
[
i
],
value
))
{
return
mp_obj_new_int
(
i
);
}
...
...
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