Skip to content

Commit 307b0bb

Browse files
committed
Revert "Handle StopIteration in Python 3.7+"
This reverts commit 701712f.
1 parent 701712f commit 307b0bb

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

toolz/itertoolz.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,8 @@ def second(seq):
375375
'B'
376376
"""
377377
seq = iter(seq)
378-
try:
379-
next(seq)
380-
return next(seq)
381-
except StopIteration:
382-
raise
378+
next(seq)
379+
return next(seq)
383380

384381

385382
def nth(n, seq):

toolz/tests/test_itertoolz.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from toolz.compatibility import range, filter
1818
from operator import add, mul
1919

20-
import pytest
21-
2220

2321
# is comparison will fail between this and no_default
2422
no_default2 = loads(dumps('__no__default__'))
@@ -145,12 +143,6 @@ def test_second():
145143
assert second('ABCDE') == 'B'
146144
assert second((3, 2, 1)) == 2
147145
assert isinstance(second({0: 'zero', 1: 'one'}), int)
148-
assert second(x for x in range(2)) == 1
149-
150-
# Python 3.7, StopIteration should be raised if iterable too short
151-
with pytest.raises(StopIteration):
152-
second([])
153-
second([0])
154146

155147

156148
def test_last():

0 commit comments

Comments
 (0)