summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-26 18:47:56 (GMT)
committerGitHub <noreply@github.com>2017-09-26 18:47:56 (GMT)
commitc740e4fe8a9bc5815dc18c38d7f7600b128c3c51 (patch)
tree6edda52b98ac544e918d237abc2d2f60d185861b /Lib/test
parent114454e9f6addbcb364e9a37102c8131ae2da1dd (diff)
downloadcpython-c740e4fe8a9bc5815dc18c38d7f7600b128c3c51.zip
cpython-c740e4fe8a9bc5815dc18c38d7f7600b128c3c51.tar.gz
cpython-c740e4fe8a9bc5815dc18c38d7f7600b128c3c51.tar.bz2
bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (#1557)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_itertools.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 8353e68..a359905 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -2017,6 +2017,30 @@ class RegressionTests(unittest.TestCase):
with self.assertRaises(StopIteration):
next(it)
+ def test_issue30347_1(self):
+ def f(n):
+ if n == 5:
+ list(b)
+ return n != 6
+ for (k, b) in groupby(range(10), f):
+ list(b) # shouldn't crash
+
+ def test_issue30347_2(self):
+ class K:
+ def __init__(self, v):
+ pass
+ def __eq__(self, other):
+ nonlocal i
+ i += 1
+ if i == 1:
+ next(g, None)
+ return True
+ i = 0
+ g = next(groupby(range(10), K))[1]
+ for j in range(2):
+ next(g, None) # shouldn't crash
+
+
class SubclassWithKwargsTest(unittest.TestCase):
def test_keywords_in_subclass(self):
# count is not subclassable...