Closed
Description
While writing tests for a different issue, noticed a few differences with the current islice
implementation.
Some examples:
>>> import adafruit_itertools as ait
>>> import itertools as it
>>> list(it.islice("ab", 10))
['a', 'b']
>>> list(ait.islice("ab", 10))
Traceback (most recent call last):
File "/home/kbs/venv/lib/python3.8/site-packages/adafruit_itertools/__init__.py", line 353, in islice
yield next(it)
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: generator raised StopIteration
>>> list(it.islice("ab", -1))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.
>>> list(ait.islice("ab", -1))
[]
>>>
I can follow-up with a fix to more closely align the behavior, if this feels worth fixing?
Metadata
Metadata
Assignees
Labels
No labels