]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)
authorEric Snow <ericsnowcurrently@gmail.com>
Mon, 31 Oct 2022 19:35:54 +0000 (13:35 -0600)
committerGitHub <noreply@github.com>
Mon, 31 Oct 2022 19:35:54 +0000 (12:35 -0700)
commit4702552885811d0af8f0e4545f494336801ad4dd
treea8d24ed97f3e4561bf79ce6d27bd46cba2ecb303
parent3b86538661038ee23d0be80bb7593e2e7856f059
gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)

Previously, the optional restrictions on subinterpreters were: disallow fork, subprocess, and threads.  By default, we were disallowing all three for "isolated" interpreters.  We always allowed all three for the main interpreter and those created through the legacy `Py_NewInterpreter()` API.

Those settings were a bit conservative, so here we've adjusted the optional restrictions to: fork, exec, threads, and daemon threads.  The default for "isolated" interpreters disables fork, exec, and daemon threads.  Regular threads are allowed by default.  We continue always allowing everything For the main interpreter and the legacy API.

In the code, we add `_PyInterpreterConfig.allow_exec` and  `_PyInterpreterConfig.allow_daemon_threads`.  We also add `Py_RTFLAGS_DAEMON_THREADS` and `Py_RTFLAGS_EXEC`.
15 files changed:
Include/cpython/initconfig.h
Include/cpython/pystate.h
Lib/test/test__xxsubinterpreters.py
Lib/test/test_capi.py
Lib/test/test_embed.py
Lib/test/test_threading.py
Lib/threading.py
Misc/NEWS.d/next/C API/2022-10-24-12-09-17.gh-issue-98610.PLX2Np.rst [new file with mode: 0644]
Modules/_posixsubprocess.c
Modules/_testcapimodule.c
Modules/_threadmodule.c
Modules/_winapi.c
Modules/_xxsubinterpretersmodule.c
Modules/posixmodule.c
Python/pylifecycle.c