Skip to content

Commit 2b3e02a

Browse files
gh-101277: Isolate itertools, add group and _grouper types to module state (#101302)
Co-authored-by: Kumar Aditya <[email protected]>
1 parent cc407b9 commit 2b3e02a

File tree

3 files changed

+173
-111
lines changed

3 files changed

+173
-111
lines changed

Lib/test/test_itertools.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,38 @@ def test_zip_longest_result_gc(self):
16941694
gc.collect()
16951695
self.assertTrue(gc.is_tracked(next(it)))
16961696

1697+
@support.cpython_only
1698+
def test_immutable_types(self):
1699+
from itertools import _grouper, _tee, _tee_dataobject
1700+
dataset = (
1701+
accumulate,
1702+
batched,
1703+
chain,
1704+
combinations,
1705+
combinations_with_replacement,
1706+
compress,
1707+
count,
1708+
cycle,
1709+
dropwhile,
1710+
filterfalse,
1711+
groupby,
1712+
_grouper,
1713+
islice,
1714+
pairwise,
1715+
permutations,
1716+
product,
1717+
repeat,
1718+
starmap,
1719+
takewhile,
1720+
_tee,
1721+
_tee_dataobject,
1722+
zip_longest,
1723+
)
1724+
for tp in dataset:
1725+
with self.subTest(tp=tp):
1726+
with self.assertRaisesRegex(TypeError, "immutable"):
1727+
tp.foobar = 1
1728+
16971729

16981730
class TestExamples(unittest.TestCase):
16991731

Modules/clinic/itertoolsmodule.c.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)