From 9fc88f42e04bc228f0fa359c324d0fd93cf18d7e Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 12 Mar 2024 17:49:10 +0000 Subject: [PATCH] gh-116749: Disable GIL by default in free-threaded build Switch GIL to disabled by default in free-threaded build so that the free-threaded CIs catch thread-safety issues. --- Lib/test/test_cmd_line.py | 2 +- Lib/test/test_embed.py | 2 +- Python/initconfig.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 9624d35d0c3948..15932022ee111a 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -884,7 +884,7 @@ def test_pythondevmode_env(self): def test_python_gil(self): cases = [ # (env, opt, expected, msg) - (None, None, 'None', "no options set"), + (None, None, '0', "no options set"), ('0', None, '0', "PYTHON_GIL=0"), ('1', None, '1', "PYTHON_GIL=1"), ('1', '0', '0', "-X gil=0 overrides PYTHON_GIL=1"), diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index d94c63a13b8ea4..14026095a76d6f 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -534,7 +534,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): if support.Py_DEBUG: CONFIG_COMPAT['run_presite'] = None if support.Py_GIL_DISABLED: - CONFIG_COMPAT['enable_gil'] = -1 + CONFIG_COMPAT['enable_gil'] = 0 if MS_WINDOWS: CONFIG_COMPAT.update({ 'legacy_windows_stdio': 0, diff --git a/Python/initconfig.c b/Python/initconfig.c index d91a8199b544dc..d70413f21ea954 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -847,7 +847,7 @@ _PyConfig_InitCompatConfig(PyConfig *config) config->code_debug_ranges = 1; config->cpu_count = -1; #ifdef Py_GIL_DISABLED - config->enable_gil = _PyConfig_GIL_DEFAULT; + config->enable_gil = _PyConfig_GIL_DISABLE; #endif }