Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145142: Make str.maketrans safe under free-threading#145157

Merged
colesbury merged 13 commits intopython:mainfrom
VanshAgarwal24036:gh-145142-dict-next-critical-section
Feb 27, 2026
Merged

gh-145142: Make str.maketrans safe under free-threading#145157
colesbury merged 13 commits intopython:mainfrom
VanshAgarwal24036:gh-145142-dict-next-critical-section

Conversation

@VanshAgarwal24036
Copy link
Contributor

@VanshAgarwal24036VanshAgarwal24036 commentedFeb 23, 2026
edited by bedevere-appbot
Loading

Replace unsafe PyDict_Next iteration with snapshot iteration using PyDict_Items to avoid crashes when the input dict is mutated concurrently under free-threading.

Adds a regression test.

Copy link
Contributor

@colesburycolesbury left a comment

Choose a reason for hiding this comment

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

A few comments below

Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

Choose a reason for hiding this comment

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

I would suggest isolating the loop in a separate function so that we do not have those weird labels jumps and confusing names but this should be benchmarked on PGO/LTO tocheck that we do not introduce an overhead (though I am not that worried as str.maketrans() is usually not a hot function).

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Contributor

@sharktidesharktide left a comment
edited
Loading

Choose a reason for hiding this comment

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

Bunch of syntax errors you need to fix as well.

I also agree with picnixz’s comments

@VanshAgarwal24036VanshAgarwal24036 marked this pull request as draftFebruary 24, 2026 12:44
@VanshAgarwal24036VanshAgarwal24036force-pushed thegh-145142-dict-next-critical-section branch fromd487864 to05ba3f3CompareFebruary 24, 2026 15:57
@VanshAgarwal24036VanshAgarwal24036 marked this pull request as ready for reviewFebruary 24, 2026 16:37
@VanshAgarwal24036VanshAgarwal24036force-pushed thegh-145142-dict-next-critical-section branch from206f6b2 to4e715b0CompareFebruary 24, 2026 17:34
@VanshAgarwal24036
Copy link
ContributorAuthor

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

Copy link
Contributor

@colesburycolesbury left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@colesburycolesbury added the needs backport to 3.14bugs and security fixes labelFeb 27, 2026
@colesburycolesburyenabled auto-merge (squash)February 27, 2026 15:41
}

static int
unicode_maketrans_from_dict(PyObject *x, PyObject *newdict)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
unicode_maketrans_from_dict(PyObject*x,PyObject*newdict)
unicode_maketrans_from_dict_lock_held(PyObject*x,PyObject*newdict)

Naming convention for methods that require locking.

@colesburycolesbury merged commita249795 intopython:mainFeb 27, 2026
47 checks passed
@miss-islington-app
Copy link

Thanks@VanshAgarwal24036 for the PR, and@colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 27, 2026
…gh-145157)(cherry picked from commita249795)Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
@bedevere-app
Copy link

GH-145320 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelFeb 27, 2026
colesbury pushed a commit that referenced this pull requestFeb 27, 2026
…5157) (#145320)Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
@VanshAgarwal24036VanshAgarwal24036 deleted the gh-145142-dict-next-critical-section branchFebruary 27, 2026 16:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@eendebakpteendebakpteendebakpt left review comments

@colesburycolesburycolesbury approved these changes

@picnixzpicnixzpicnixz approved these changes

@sharktidesharktideAwaiting requested review from sharktide

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@VanshAgarwal24036@colesbury@eendebakpt@picnixz@sharktide

[8]ページ先頭

©2009-2026 Movatter.jp