summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-09-26 19:20:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-09-26 19:20:22 (GMT)
commit69b2dc8637ba924d78f9869be592c5a545510f10 (patch)
treec780196933559436c173e7bd072ce548e6ea472d /Lib
parentd6a356209abd026b41245ad76ba3a374ab0c60db (diff)
downloadcpython-69b2dc8637ba924d78f9869be592c5a545510f10.zip
cpython-69b2dc8637ba924d78f9869be592c5a545510f10.tar.gz
cpython-69b2dc8637ba924d78f9869be592c5a545510f10.tar.bz2
[3.6] bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (GH-1557) (#3770)
(cherry picked from commit c740e4fe8a9bc5815dc18c38d7f7600b128c3c51)
Diffstat (limited to 'Lib')
-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 c431f0d..a978134 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -1984,6 +1984,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...