Uh oh!
There was an error while loading. Please reload this page.
gh-145142: Make str.maketrans safe under free-threading - #145157
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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 phrase |
d487864 to
05ba3f3Compare206f6b2 to
4e715b0CompareVanshAgarwal24036
commented
Feb 24, 2026
I have made the requested changes; please review again. |
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
Uh oh!
There was an error while loading. Please reload this page.
| } | ||
| static int | ||
| unicode_maketrans_from_dict(PyObject *x, PyObject *newdict) |
There was a problem hiding this comment.
| 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.
Uh oh!
There was an error while loading. Please reload this page.
Thanks @VanshAgarwal24036 for the PR, and @colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…gh-145157) (cherry picked from commit a249795) Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
GH-145320 is a backport of this pull request to the 3.14 branch. |
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.