]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-151218: Replace sys.flags in PyConfig_Set() (#151402)
authorVictor Stinner <vstinner@python.org>
Tue, 16 Jun 2026 16:17:33 +0000 (18:17 +0200)
committerGitHub <noreply@github.com>
Tue, 16 Jun 2026 16:17:33 +0000 (16:17 +0000)
commitb16d23fc9fe9cb72fa15c8a3036753e5437b5b8c
tree1ed6303f6f69cf969b5f5211a93d5d4ed60565bf
parent2ce260033b457a0ad2c9767a1d9902bef5a30b0e
gh-151218: Replace sys.flags in PyConfig_Set() (#151402)

PyConfig_Set() and sys.set_int_max_str_digits() now replace
sys.flags (create a new object), instead of modifying sys.flags in-place.

Modifying sys.flags in-place can lead to data races when multiple
threads are reading or writing sys.flags in parallel.

Use _Py_atomic functions to get and set max_str_digits members.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Doc/c-api/init_config.rst
Lib/test/test_capi/test_config.py
Lib/test/test_free_threading/test_sys.py [new file with mode: 0644]
Lib/test/test_sys.py
Misc/NEWS.d/next/Core_and_Builtins/2026-06-12-15-30-25.gh-issue-151218.5M_nv8.rst [new file with mode: 0644]
Objects/longobject.c
Python/initconfig.c
Python/pylifecycle.c
Python/sysmodule.c