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):
107107 return False
108108
109109 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 ])
116111
117112 def __getitem__ (self , index ):
118113 """Return the element at position ``index`` in the sequence
Original file line number Diff line number Diff line change 66from future .builtins import range
77from future .tests .base import unittest
88
9- from collections import Sequence
9+ from collections import Iterator , Sequence
1010
1111
1212class RangeTests (unittest .TestCase ):
1313 def test_range (self ):
1414 self .assertTrue (isinstance (range (0 ), Sequence ))
15+ self .assertTrue (isinstance (reversed (range (0 )), Iterator ))
1516
1617 def test_bool_range (self ):
1718 self .assertFalse (range (0 ))
You can’t perform that action at this time.
0 commit comments