Skip to content

Commit

Permalink
Update Range.__getitem__ for boolean indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeadle committed Aug 18, 2017
1 parent f7c1526 commit 8e2f7b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 6 additions & 1 deletion python/common/org/python/types/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ public org.python.Object __getitem__(org.python.Object index) {
return new org.python.types.Range(substart, substop, substep);
} else {
long len = ((org.python.types.Int) (this.__len__())).value;
long idx = ((org.python.types.Int) index).value;
long idx;
if (index instanceof org.python.types.Bool) {
idx = ((org.python.types.Bool)index).value ? 1 : 0;
} else {
idx = ((org.python.types.Int) index).value;
}

if (idx < 0) {
idx = len + idx;
Expand Down
4 changes: 0 additions & 4 deletions tests/datatypes/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ class UnaryRangeOperationTests(UnaryOperationTestCase, TranspileTestCase):
class BinaryRangeOperationTests(BinaryOperationTestCase, TranspileTestCase):
data_type = 'range'

not_implemented = [
'test_subscr_bool',
]

not_implemented_versions = {
'test_subscr_None': (3.4,),
'test_subscr_NotImplemented': (3.4,),
Expand Down

0 comments on commit 8e2f7b1

Please sign in to comment.