summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-05-03 15:09:57 (GMT)
committerGitHub <noreply@github.com>2024-05-03 15:09:57 (GMT)
commit2dae505e87e3815f087d4b07a71bb2c5cce22304 (patch)
tree232577513b53b378623dc28c7dae53c846b2bf77 /Lib/test
parent24e643d4ef024a3561c927dc07c59c435bb27bcc (diff)
downloadcpython-2dae505e87e3815f087d4b07a71bb2c5cce22304.zip
cpython-2dae505e87e3815f087d4b07a71bb2c5cce22304.tar.gz
cpython-2dae505e87e3815f087d4b07a71bb2c5cce22304.tar.bz2
gh-117514: Add `sys._is_gil_enabled()` function (#118514)
The function returns `True` or `False` depending on whether the GIL is currently enabled. In the default build, it always returns `True` because the GIL is always enabled.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_sys.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 14ec51e..df0a6f0 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -1053,6 +1053,12 @@ class SysModuleTest(unittest.TestCase):
c = sys.getallocatedblocks()
self.assertIn(c, range(b - 50, b + 50))
+ def test_is_gil_enabled(self):
+ if support.Py_GIL_DISABLED:
+ self.assertIs(type(sys._is_gil_enabled()), bool)
+ else:
+ self.assertTrue(sys._is_gil_enabled())
+
def test_is_finalizing(self):
self.assertIs(sys.is_finalizing(), False)
# Don't use the atexit module because _Py_Finalizing is only set