summaryrefslogtreecommitdiff
path: root/Include/cpython
diff options
context:
space:
mode:
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/initconfig.h19
-rw-r--r--Include/cpython/pylifecycle.h3
-rw-r--r--Include/cpython/pystate.h27
3 files changed, 44 insertions, 5 deletions
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index c22c8d52b4..64748cf78b 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -213,10 +213,6 @@ typedef struct PyConfig {
// If equal to 0, stop Python initialization before the "main" phase.
int _init_main;
- // If non-zero, disallow threads, subprocesses, and fork.
- // Default: 0.
- int _isolated_interpreter;
-
// If non-zero, we believe we're running from a source tree.
int _is_python_build;
} PyConfig;
@@ -245,6 +241,21 @@ PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
Py_ssize_t length, wchar_t **items);
+/* --- PyInterpreterConfig ------------------------------------ */
+
+typedef struct {
+ int allow_fork;
+ int allow_subprocess;
+ int allow_threads;
+} _PyInterpreterConfig;
+
+#define _PyInterpreterConfig_LEGACY_INIT \
+ { \
+ .allow_fork = 1, \
+ .allow_subprocess = 1, \
+ .allow_threads = 1, \
+ }
+
/* --- Helper functions --------------------------------------- */
/* Get the original command line arguments, before Python modified them.
diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h
index bb5b07ef59..e1f83acbff 100644
--- a/Include/cpython/pylifecycle.h
+++ b/Include/cpython/pylifecycle.h
@@ -62,4 +62,5 @@ 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_NewInterpreter(int isolated_subinterpreter);
+PyAPI_FUNC(PyThreadState *) _Py_NewInterpreterFromConfig(
+ const _PyInterpreterConfig *);
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 7722a384cb..7996bd34ea 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -3,11 +3,38 @@
#endif
+/*
+Runtime Feature Flags
+
+Each flag indicate whether or not a specific runtime feature
+is available in a given context. For example, forking the process
+might not be allowed in the current interpreter (i.e. os.fork() would fail).
+*/
+
+// We leave the first 10 for less-specific features.
+
+/* Set if threads are allowed. */
+#define Py_RTFLAGS_THREADS (1UL << 10)
+
+/* Set if os.fork() is allowed. */
+#define Py_RTFLAGS_FORK (1UL << 15)
+
+/* Set if subprocesses are allowed. */
+#define Py_RTFLAGS_SUBPROCESS (1UL << 16)
+
+
+PyAPI_FUNC(int) _PyInterpreterState_HasFeature(PyInterpreterState *interp,
+ unsigned long feature);
+
+
+/* private interpreter helpers */
+
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetMainModule(PyInterpreterState *);
+
/* State unique per thread */
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */