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
f0691f4e
Commit
f0691f4e
authored
Jan 05, 2014
by
Damien George
Browse files
Fix qstr in objlist.c; add more tests for list.index.
list.index fails on an edge case.
parent
a3ab68e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/objlist.c
View file @
f0691f4e
...
...
@@ -194,7 +194,7 @@ static mp_obj_t list_index(int n_args, const mp_obj_t *args) {
}
}
nlr_jump
(
mp_obj_new_exception_msg
(
rt_q
_ValueError
,
"
O
bject not in list
.
"
));
nlr_jump
(
mp_obj_new_exception_msg
(
MP_QSTR
_ValueError
,
"
o
bject not in list"
));
}
static
MP_DEFINE_CONST_FUN_OBJ_2
(
list_append_obj
,
mp_obj_list_append
);
...
...
tests/basics/tests/list_index.py
View file @
f0691f4e
a
=
[
1
,
2
,
3
]
print
(
a
.
index
(
1
))
print
(
a
.
index
(
2
))
print
(
a
.
index
(
3
))
print
(
a
.
index
(
3
,
2
))
try
:
print
(
a
.
index
(
3
,
2
,
2
))
except
ValueError
:
print
(
"Raised ValueError"
)
else
:
print
(
"Did not raise ValueError"
)
a
=
a
+
a
b
=
[
0
,
0
,
a
]
print
(
a
.
index
(
2
))
print
(
b
.
index
(
a
))
print
(
a
.
index
(
2
,
2
))
try
:
a
.
index
(
2
,
2
,
2
)
except
ValueError
:
print
(
"Raised ValueError"
)
else
:
raise
AssertionError
(
"Did not raise ValueError"
)
print
(
"Did not raise ValueError"
)
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