]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-153056: Backport the relevant bits of (#153057) (#153369)
authorBarry Warsaw <barry@python.org>
Thu, 9 Jul 2026 19:40:59 +0000 (12:40 -0700)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2026 19:40:59 +0000 (19:40 +0000)
commit7994b41154279a2c7d22456a5c200e1fa662b931
treeab1c39cfd8ab57f6860b9e1b64a98b30235c80fc
parent70c8b9f81e99d93439fd841aced781427c1f5d45
[3.13] gh-153056: Backport the relevant bits of (#153057) (#153369)

gh-153056: Backport the relevant bits of (#153057)

The data race for compiling the string.Template pattern in free-threading builds is not relevant for
3.13, due to the older string.Template and string.py module implementation.  However, the secondary
bug identified by that isue is still relevant here, and fixed in this branch:

    As a side effect, a subclass that supplies an already-compiled pattern now works too; previously
    it raised the same ValueError at class definition.

* Document that the pattern attribute accepts a string or a compiled regex
* Comment the three states of pattern and note the documented-behavior fix in NEWS
* Update Doc/library/string.rst

---------

(cherry picked from commit 45729033bff28f8abc36c42e802cb2853c205737)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Doc/library/string.rst
Lib/string.py
Lib/test/test_string.py
Misc/NEWS.d/next/Library/2026-07-05-12-00-00.gh-issue-153056.tMpLat.rst [new file with mode: 0644]