FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-123471: Make itertools.zip_longest safe in the FT build by eendebakpt · Pull Request #146033 · python/cpython · GitHub

/ cpython Public

gh-123471: Make itertools.zip_longest safe in the FT build - #146033

Merged
kumaraditya303 merged 4 commits into
python:mainfrom
eendebakpt:ziplongest_ft
Mar 27, 2026
Merged

gh-123471: Make itertools.zip_longest safe in the FT build#146033
kumaraditya303 merged 4 commits into
python:mainfrom
eendebakpt:ziplongest_ft

Conversation

eendebakpt commented Mar 16, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

ziplongest_next is not thread safe due to setting the iterators in lz->ittuple to NULL on exhaustion. In addition, the lz->numactive is mutable state.

The usual approach to making the iterators in this module thread-safe by not setting the underlying iterator to NULL is not working here, since the NULL value is used as a signal (e.g. the check it == NULL). We therefore make the iterator safe using a critical section.

kumaraditya303 merged commit 9214e3f into python:main Mar 27, 2026
52 checks passed
nascheme added a commit that referenced this pull request Jul 17, 2026
…132814) (GH-135689) (GH-144402) (GH-146033) (GH-142957) (GH-153791)

Combined backport of PRs from main branch, fixing free-threading data-races in itertools:

* gh-123471: make concurrent iteration over `itertools.cycle` safe under free-threading (gh-131212)
* gh-123471: Make itertools.product and itertools.combinations thread-safe (GH-132814)
* gh-123471: Make itertools.chain thread-safe (gh-135689)
* gh-123471: Make concurrent iteration over `itertools.permutations` and `itertools.combinations_with_replacement` thread-safe (gh-144402)
* gh-123471: make concurrent iteration over itertools.accumulate thread-safe (gh-144486)
* gh-123471: Make `itertools.zip_longest` safe in the FT build (gh-146033)

(cherry picked from commit 26a1cd4)
(cherry picked from commit 847d1c2)
(cherry picked from commit 0533c1f)
(cherry picked from commit 009c8c0)
(cherry picked from commit 3a24856)
(cherry picked from commit 9214e3f)

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL