Skip to content

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

Open
eendebakpt wants to merge 3 commits intopython:mainfrom
eendebakpt:ziplongest_ft
Open

gh-123471: Make itertools.zip_longest safe in the FT build#146033
eendebakpt wants to merge 3 commits intopython:mainfrom
eendebakpt:ziplongest_ft

Conversation

@eendebakpt
Copy link
Contributor

@eendebakpt eendebakpt commented Mar 16, 2026

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.

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.

1 participant