Skip to content

Commit 0b80ee1

Browse files
committed
Fix islice to work with second arg None
1 parent 30b2e54 commit 0b80ee1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

graalpython/lib-graalpython/itertools.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2222
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
# DEALINGS IN THE SOFTWARE.
24+
import sys
25+
26+
2427
class repeat():
2528
def __init__(self, obj, times=None):
2629
self.obj = obj
@@ -98,7 +101,10 @@ def __next__(self):
98101
class islice(object):
99102
def __init__(self, iterable, *args):
100103
self._iterable = enumerate(iter(iterable))
101-
self._indexes = iter(range(*args))
104+
slice = list(args)
105+
if len(slice) >= 2 and slice[1] is None:
106+
slice[1] = sys.maxsize
107+
self._indexes = iter(range(*slice))
102108

103109
def __iter__(self):
104110
return self

0 commit comments

Comments
 (0)