gh-123471: Make concurrent iteration over itertools.pairwise safe under free-threading by eendebakpt · Pull Request #123848 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Lib/test/test_free_threading/test_itertools.py
26 changes: 1 addition & 25 deletions Lib/test/test_itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,35 +902,11 @@ def __next__(self):
(([2], [3]), [4]),
([4], [5]),
])
check({2}, [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are passed for equivalent Python implementation. So it is reasonable to expect them passing for any correct C implementation.

Originally the purpose of these tests was to test bugs with using borrowed references. After removing them we cannot be sure that the bugs will not return. If you need to remove them, then perhaps the bugs returned.

([1], ([1], [3])),
(([1], [3]), [4]),
([4], [5]),
])
check({3}, [
([1], [2]),
([2], ([2], [4])),
(([2], [4]), [5]),
([5], [6]),
])
check({1, 2}, [
((([3], [4]), [5]), [6]),
([6], [7]),
])
check({1, 3}, [
(([2], ([2], [4])), [5]),
([5], [6]),
])
check({1, 4}, [
(([2], [3]), (([2], [3]), [5])),
((([2], [3]), [5]), [6]),
([6], [7]),
])
check({2, 3}, [
([1], ([1], ([1], [4]))),
(([1], ([1], [4])), [5]),
([5], [6]),
])


def test_pairwise_reenter2(self):
def check(maxcount, expected):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make concurrent iterations over the same :func:`itertools.pairwise` iterator safe under free-threading.
77 changes: 72 additions & 5 deletions Modules/itertoolsmodule.c