Skip to content

Commit 0566a7c

Browse files
committed
gh-135645: Added supports_isolated_interpreters to sys.implementation
1 parent 0d582de commit 0566a7c

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

Doc/library/sys.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@ always available. Unless explicitly noted otherwise, all variables are read-only
11851185
``cache_tag`` is set to ``None``, it indicates that module caching should
11861186
be disabled.
11871187

1188+
*supports_isolated_interpreters* is a boolean value, whether
1189+
this implementation supports :pep:`734`. It is always ``True`` for CPython.
1190+
11881191
:data:`sys.implementation` may contain additional attributes specific to
11891192
the Python implementation. These non-standard attributes must start with
11901193
an underscore, and are not described here. Regardless of its contents,
@@ -1194,6 +1197,9 @@ always available. Unless explicitly noted otherwise, all variables are read-only
11941197

11951198
.. versionadded:: 3.3
11961199

1200+
.. versionchanged:: 3.14
1201+
Added ``supports_isolated_interpreters`` field.
1202+
11971203
.. note::
11981204

11991205
The addition of new required attributes must go through the normal PEP

Lib/test/test_sys.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,11 @@ def test_implementation(self):
10871087
self.assertEqual(sys.implementation.name,
10881088
sys.implementation.name.lower())
10891089

1090+
@test.support.cpython_only
1091+
def test_supports_isolated_interpreters(self):
1092+
# https://peps.python.org/pep-0734
1093+
self.assertIs(sys.implementation.supports_isolated_interpreters, True)
1094+
10901095
@test.support.cpython_only
10911096
def test_debugmallocstats(self):
10921097
# Test sys._debugmallocstats()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added ``supports_isolated_interpreters`` field to
2+
:data:`sys.implementation`.

Python/sysmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,11 @@ make_impl_info(PyObject *version_info)
36023602
goto error;
36033603
#endif
36043604

3605+
res = PyDict_SetItemString(impl_info, "supports_isolated_interpreters",
3606+
Py_NewRef(Py_True)); // PEP-734
3607+
if (res < 0)
3608+
goto error;
3609+
36053610
/* dict ready */
36063611

36073612
ns = _PyNamespace_New(impl_info);

0 commit comments

Comments
 (0)