cpython/Programs
Eric Snow f32369480d
gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() (gh-98609)
(see https://github.com/python/cpython/issues/98608)

This change does the following:

1. change the argument to a new `_PyInterpreterConfig` struct
2. rename the function to `_Py_NewInterpreterFromConfig()`, inspired by `Py_InitializeFromConfig()` (takes a `_PyInterpreterConfig`  instead of `isolated_subinterpreter`)
3. split up the boolean `isolated_subinterpreter` into the corresponding multiple granular settings
   * allow_fork
   * allow_subprocess
   * allow_threads
4. add `PyInterpreterState.feature_flags` to store those settings
5. add a function for checking if a feature is enabled on an opaque `PyInterpreterState *`
6. drop `PyConfig._isolated_interpreter`

The existing default (see `Py_NewInterpeter()` and `Py_Initialize*()`) allows fork, subprocess, and threads and the optional "isolated" interpreter (see the `_xxsubinterpreters` module) disables all three.  None of that changes here; the defaults are preserved.

Note that the given `_PyInterpreterConfig` will not be used outside `_Py_NewInterpreterFromConfig()`, nor preserved.  This contrasts with how `PyConfig` is currently preserved, used, and even modified outside `Py_InitializeFromConfig()`.  I'd rather just avoid that mess from the start for `_PyInterpreterConfig`.  We can preserve it later if we find an actual need.

This change allows us to follow up with a number of improvements (e.g. stop disallowing subprocess and support disallowing exec instead).

(Note that this PR adds "private" symbols.  We'll probably make them public, and add docs, in a separate change.)
2022-10-26 11:16:30 -06:00
..
_bootstrap_python.c gh-97669: Create Tools/build/ directory (#97963) 2022-10-17 12:01:00 +02:00
_freeze_module.c gh-97669: Create Tools/build/ directory (#97963) 2022-10-17 12:01:00 +02:00
_freeze_module.py bpo-45949: Pure Python freeze module for cross builds (GH-29899) 2021-12-13 20:48:46 +01:00
_testembed.c gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() (gh-98609) 2022-10-26 11:16:30 -06:00
freeze_test_frozenmain.py bpo-44131: Test Py_FrozenMain() (GH-26126) 2021-05-17 23:48:35 +02:00
python.c bpo-40268: Remove unused imports in pylifecycle.c (GH-19533) 2020-04-15 04:01:58 +02:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
test_frozenmain.h gh-94485: Set line number of module's RESUME instruction to 0, as specified by PEP 626 (GH-94552) 2022-07-05 14:38:44 +02:00
test_frozenmain.py bpo-44131: Py_FrozenMain() uses PyConfig_SetBytesArgv() (GH-26201) 2021-05-20 12:08:05 +02:00

Source files for binary executables (as opposed to shared modules)