diff --git a/py/range.go b/py/range.go index 4dc0358e..922a235d 100644 --- a/py/range.go +++ b/py/range.go @@ -98,7 +98,11 @@ func (it *RangeIterator) M__iter__() (Object, error) { // Range iterator next func (it *RangeIterator) M__next__() (Object, error) { r := it.Index - if r >= it.Stop { + if it.Step >= 0 && r >= it.Stop { + return nil, StopIteration + } + + if it.Step < 0 && r <= it.Stop { return nil, StopIteration } it.Index += it.Step diff --git a/py/tests/range.py b/py/tests/range.py index 327ecfa5..968778bb 100644 --- a/py/tests/range.py +++ b/py/tests/range.py @@ -13,4 +13,9 @@ b = [e for e in a] assert len(a) == len(b) +a = range(100, 0, -1) +b = [e for e in a] +assert len(a) == 100 +assert len(b) == 100 + doc="finished" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy