File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -107,12 +107,7 @@ def __contains__(self, value):
107
107
return False
108
108
109
109
def __reversed__ (self ):
110
- """Return a range which represents a sequence whose
111
- contents are the same as the sequence this range
112
- represents, but in the opposite order."""
113
- sign = self ._step / abs (self ._step )
114
- last = self ._start + ((self ._len - 1 ) * self ._step )
115
- return newrange (last , self ._start - sign , - 1 * self ._step )
110
+ return iter (self [::- 1 ])
116
111
117
112
def __getitem__ (self , index ):
118
113
"""Return the element at position ``index`` in the sequence
Original file line number Diff line number Diff line change 6
6
from future .builtins import range
7
7
from future .tests .base import unittest
8
8
9
- from collections import Sequence
9
+ from collections import Iterator , Sequence
10
10
11
11
12
12
class RangeTests (unittest .TestCase ):
13
13
def test_range (self ):
14
14
self .assertTrue (isinstance (range (0 ), Sequence ))
15
+ self .assertTrue (isinstance (reversed (range (0 )), Iterator ))
15
16
16
17
def test_bool_range (self ):
17
18
self .assertFalse (range (0 ))
You can’t perform that action at this time.
0 commit comments