Skip to content

Commit

Permalink
pythongh-108223: Refer to PEP 703 as Free Threading
Browse files Browse the repository at this point in the history
Rename support.Py_GIL_DISABLED to support.FREE_THREADING.
  • Loading branch information
vstinner committed Dec 5, 2023
1 parent d384813 commit 6606ae2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ General Options
.. option:: --disable-gil

Enables **experimental** support for running Python without the
:term:`global interpreter lock` (GIL).
:term:`global interpreter lock` (GIL): free threading build.

Define the ``Py_GIL_DISABLED`` macro and add ``"t"`` to
:data:`sys.abiflags`.

See :pep:`703` "Making the Global Interpreter Lock Optional in CPython".

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def get_build_info():

# --disable-gil
if sysconfig.get_config_var('Py_GIL_DISABLED'):
build.append("nogil")
build.append("freethreading")

if hasattr(sys, 'gettotalrefcount'):
# --with-pydebug
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ def check_cflags_pgo():
return any(option in cflags_nodist for option in pgo_options)


Py_GIL_DISABLED = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
if Py_GIL_DISABLED:
FREE_THREADING = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
if FREE_THREADING:
_header = 'PHBBInP'
else:
_header = 'nP'
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2854,7 +2854,7 @@ def testfunc(n, m):
self.assertIn("_FOR_ITER_TIER_TWO", uops)


@unittest.skipUnless(support.Py_GIL_DISABLED, 'need Py_GIL_DISABLED')
@unittest.skipUnless(support.FREE_THREADING, 'need free threading')
class TestPyThreadId(unittest.TestCase):
def test_py_thread_id(self):
# gh-112535: Test _Py_ThreadId(): make sure that thread identifiers
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_cppext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

# gh-110119: pip does not currently support 't' in the ABI flag use by
# --disable-gil builds. Once it does, we can remove this skip.
@unittest.skipIf(support.Py_GIL_DISABLED,
'test does not work with --disable-gil')
@unittest.skipIf(support.FREE_THREADING,
'test does not work with free threading')
@support.requires_subprocess()
class TestCPPExt(unittest.TestCase):
@support.requires_resource('cpu')
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_importlib/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_module_not_found(self):
class WindowsExtensionSuffixTests:
def test_tagged_suffix(self):
suffixes = self.machinery.EXTENSION_SUFFIXES
abi_flags = "t" if support.Py_GIL_DISABLED else ""
abi_flags = "t" if support.FREE_THREADING else ""
ver = sys.version_info
platform = re.sub('[^a-zA-Z0-9]', '_', get_platform())
expected_tag = f".cp{ver.major}{ver.minor}{abi_flags}-{platform}.pyd"
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def test_pystats(self):
@test.support.cpython_only
@unittest.skipUnless(hasattr(sys, 'abiflags'), 'need sys.abiflags')
def test_disable_gil_abi(self):
self.assertEqual('t' in sys.abiflags, support.Py_GIL_DISABLED)
self.assertEqual('t' in sys.abiflags, support.FREE_THREADING)


@test.support.cpython_only
Expand Down

0 comments on commit 6606ae2

Please sign in to comment.