mirror of
https://github.com/python/cpython.git
synced 2025-11-15 08:01:29 +00:00
(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.)
66 lines
2.1 KiB
C
66 lines
2.1 KiB
C
#ifndef Py_CPYTHON_PYLIFECYCLE_H
|
|
# error "this header file must not be included directly"
|
|
#endif
|
|
|
|
/* Py_FrozenMain is kept out of the Limited API until documented and present
|
|
in all builds of Python */
|
|
PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
|
|
|
|
/* Only used by applications that embed the interpreter and need to
|
|
* override the standard encoding determination mechanism
|
|
*/
|
|
Py_DEPRECATED(3.11) PyAPI_FUNC(int) Py_SetStandardStreamEncoding(
|
|
const char *encoding,
|
|
const char *errors);
|
|
|
|
/* PEP 432 Multi-phase initialization API (Private while provisional!) */
|
|
|
|
PyAPI_FUNC(PyStatus) Py_PreInitialize(
|
|
const PyPreConfig *src_config);
|
|
PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs(
|
|
const PyPreConfig *src_config,
|
|
Py_ssize_t argc,
|
|
char **argv);
|
|
PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
|
|
const PyPreConfig *src_config,
|
|
Py_ssize_t argc,
|
|
wchar_t **argv);
|
|
|
|
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
|
|
|
|
|
|
/* Initialization and finalization */
|
|
|
|
PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
|
|
const PyConfig *config);
|
|
PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
|
|
|
|
PyAPI_FUNC(int) Py_RunMain(void);
|
|
|
|
|
|
PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
|
|
|
|
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
|
|
PyAPI_FUNC(void) _Py_RestoreSignals(void);
|
|
|
|
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
|
|
PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
|
|
|
|
Py_DEPRECATED(3.11) PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
|
|
|
|
PyAPI_FUNC(const char *) _Py_gitidentifier(void);
|
|
PyAPI_FUNC(const char *) _Py_gitversion(void);
|
|
|
|
PyAPI_FUNC(int) _Py_IsFinalizing(void);
|
|
|
|
/* Random */
|
|
PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
|
|
PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
|
|
|
|
/* Legacy locale support */
|
|
PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
|
|
PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
|
|
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
|
|
|
|
PyAPI_FUNC(PyThreadState *) _Py_NewInterpreterFromConfig(
|
|
const _PyInterpreterConfig *);
|