You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
- added checks during iteration to handle "short" iterators
- added tests to run some basic comparisons between CP and
this library for `islice`.
Fixesadafruit#22
While writing tests for a different issue, noticed a few differences with the current
islice
implementation.Some examples:
I can follow-up with a fix to more closely align the behavior, if this feels worth fixing?
The text was updated successfully, but these errors were encountered: