Repository navigation
gh-153928: make Unicode iterators thread-safe - #155873
Open
BHUVANSH855 wants to merge 4 commits into
Open
BHUVANSH855 wants to merge 4 commits into
BHUVANSH855 wants to merge 4 commits into
Conversation
picnixz
reviewed
Aug 15, 2026
Contributor
Author
|
@picnixz gentle ping ! |
picnixz
reviewed
Oct 22, 2026
picnixz
left a comment
Member
There was a problem hiding this comment.
I'm not confident enough here. I am afraid that this could slightly affect the regular build if because of PGO not being able to do something.
Since the problem is also not just necessarily for str/bytes but for any iterable family, I would rather defer the decision to @kumaraditya303 for that.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix data races in Unicode iterators in free-threaded builds.
This makes
it_indexaccesses atomic in both Unicode iterator implementations and atomically exchangesit_seqwhen the iterator is exhausted so that only one thread releases the iterator-owned reference.__length_hint__and__reduce__also take a strong reference to the underlying string under a critical section before accessing it.Adds free-threading regression tests covering shared string iteration and concurrent iterator exhaustion.
Fixes issue gh-153928.