]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-123275: Add tests for `PYTHON_GIL=1` and `-Xgil=1` (gh-123754) (gh-123755)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 6 Sep 2024 02:02:05 +0000 (04:02 +0200)
committerGitHub <noreply@github.com>
Fri, 6 Sep 2024 02:02:05 +0000 (11:02 +0900)
gh-123275: Add tests for `PYTHON_GIL=1` and `-Xgil=1` (gh-123754)
(cherry picked from commit fe24b718d231317516f96f896e7c17a4166f25a7)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Lib/test/test_cmd_line.py

index 9624d35d0c3948ecead96f7ef62b5b0dacad64f3..dc420f33c233af2463600b4e3ed30af93cac0a7c 100644 (file)
@@ -879,19 +879,29 @@ class CmdLineTest(unittest.TestCase):
         self.assertEqual(proc.stdout.rstrip(), 'True')
         self.assertEqual(proc.returncode, 0, proc)
 
-    @unittest.skipUnless(support.Py_GIL_DISABLED,
-                         "PYTHON_GIL and -X gil only supported in Py_GIL_DISABLED builds")
     def test_python_gil(self):
         cases = [
             # (env, opt, expected, msg)
-            (None, None, 'None', "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"),
-            (None, '0', '0', "-X gil=0"),
             (None, '1', '1', "-X gil=1"),
         ]
 
+        if support.Py_GIL_DISABLED:
+            cases.extend(
+                [
+                    (None, None, 'None', "no options set"),
+                    ('0', None, '0', "PYTHON_GIL=0"),
+                    ('1', '0', '0', "-X gil=0 overrides PYTHON_GIL=1"),
+                    (None, '0', '0', "-X gil=0"),
+                ]
+            )
+        else:
+            cases.extend(
+                [
+                    (None, None, '1', '-X gil=0 (unsupported by this build)'),
+                    ('1', None, '1', 'PYTHON_GIL=0 (unsupported by this build)'),
+                ]
+            )
         code = "import sys; print(sys.flags.gil)"
         environ = dict(os.environ)