Skip to content

Commit 7b6d6c7

Browse files
committed
[GR-9749] List.index ends with IndexError instead ValueError.
PullRequest: graalpython-open/35
2 parents 5d78ba5 + 4469bd8 commit 7b6d6c7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

graalpython/com.oracle.graal.python.test/src/tests/list_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def __eq__(self, other):
361361
for x, y in zip(d, e):
362362
# verify that original order and values are retained.
363363
self.assertIs(x, y)
364-
'''
364+
365365
def test_count(self):
366366
a = self.type2test([0, 1, 2])*3
367367
self.assertEqual(a.count(0), 3)
@@ -447,7 +447,7 @@ def test_reverse(self):
447447
self.assertEqual(u, u2)
448448

449449
self.assertRaises(TypeError, u.reverse, 42)
450-
'''
450+
451451
def test_clear(self):
452452
u = self.type2test([2, 3, 4])
453453
u.clear()

graalpython/com.oracle.graal.python.test/src/tests/test_list.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ class MyInt(int):
303303
a = [1,2,3]
304304
a.remove(MyInt(2))
305305
self.assertEqual([1,3], a)
306+
306307
def test_insert_spec(self):
307308
a = [1,2]
308309
self.assertRaises(TypeError, a.insert, [1,2,3], 1)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,7 @@ private static int correctIndex(PList list, PInt index) {
808808
}
809809

810810
private int findIndex(PList list, Object value, int start, int end, BinaryComparisonNode eqNode) {
811-
int len = list.len();
812-
for (int i = start; i < end && i < len; i++) {
811+
for (int i = start; i < end && i < list.len(); i++) {
813812
Object object = list.getItem(i);
814813
if (eqNode.executeBool(object, value)) {
815814
return i;

0 commit comments

Comments
 (0)