File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,11 @@ func (it *RangeIterator) M__iter__() (Object, error) {
90
90
// Range iterator next
91
91
func (it * RangeIterator ) M__next__ () (Object , error ) {
92
92
r := it .Index
93
- if r >= it .Stop {
93
+ if it .Step >= 0 && r >= it .Stop {
94
+ return nil , StopIteration
95
+ }
96
+
97
+ if it .Step < 0 && r <= it .Stop {
94
98
return nil , StopIteration
95
99
}
96
100
it .Index += it .Step
Original file line number Diff line number Diff line change
1
+ # Copyright 2018 The go-python Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style
3
+ # license that can be found in the LICENSE file.
4
+
5
+ doc = "range"
6
+ a = range (255 )
7
+ b = [e for e in a ]
8
+ assert len (b ) == 255
9
+ a = range (100 , 0 , - 1 )
10
+ b = [e for e in a ]
11
+ assert len (b ) == 100
12
+
13
+ doc = "finished"
You can’t perform that action at this time.
0 commit comments