Skip to content

Commit

Permalink
[3.13] gh-123275: Add tests for PYTHON_GIL=1 and -Xgil=1 (gh-123754
Browse files Browse the repository at this point in the history
…) (gh-123755)

gh-123275: Add tests for `PYTHON_GIL=1` and `-Xgil=1` (gh-123754)
(cherry picked from commit fe24b71)

Co-authored-by: Peter Bierma <[email protected]>
  • Loading branch information
miss-islington and ZeroIntensity authored Sep 6, 2024
1 parent 92b9c44 commit fb50266
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,19 +879,29 @@ def test_pythondevmode_env(self):
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)

Expand Down

0 comments on commit fb50266

Please sign in to comment.