Skip to content

Commit

Permalink
gh-101277: Isolate itertools, add group and _grouper types to module …
Browse files Browse the repository at this point in the history
…state (#101302)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
erlend-aasland and kumaraditya303 committed Feb 1, 2023
1 parent cc407b9 commit 2b3e02a
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 111 deletions.
32 changes: 32 additions & 0 deletions Lib/test/test_itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,38 @@ def test_zip_longest_result_gc(self):
gc.collect()
self.assertTrue(gc.is_tracked(next(it)))

@support.cpython_only
def test_immutable_types(self):
from itertools import _grouper, _tee, _tee_dataobject
dataset = (
accumulate,
batched,
chain,
combinations,
combinations_with_replacement,
compress,
count,
cycle,
dropwhile,
filterfalse,
groupby,
_grouper,
islice,
pairwise,
permutations,
product,
repeat,
starmap,
takewhile,
_tee,
_tee_dataobject,
zip_longest,
)
for tp in dataset:
with self.subTest(tp=tp):
with self.assertRaisesRegex(TypeError, "immutable"):
tp.foobar = 1


class TestExamples(unittest.TestCase):

Expand Down
8 changes: 4 additions & 4 deletions Modules/clinic/itertoolsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2b3e02a

Please sign in to comment.