bpo-36710: Add runtime variable to Py_InitializeEx() (GH-12939) · python/cpython@4312522 (original) (raw)

6 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ extern "C" {
8 8 # error "this header requires Py_BUILD_CORE define"
9 9 #endif
10 10
11 +#include "pycore_pystate.h" /* _PyRuntimeState */
12 +
11 13
12 14 /* --- _PyWstrList ------------------------------------------------ */
13 15
@@ -108,7 +110,8 @@ PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
108 110 const _PyCoreConfig *config);
109 111 PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config,
110 112 const _PyArgv *args);
111 -PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config);
113 +PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config,
114 +_PyRuntimeState *runtime);
112 115
113 116
114 117 /* --- Function used for testing ---------------------------------- */
Original file line number Diff line number Diff line change
@@ -34,10 +34,13 @@ extern _PyInitError _PyFaulthandler_Init(int enable);
34 34 extern int _PyTraceMalloc_Init(int enable);
35 35 extern PyObject * _PyBuiltin_Init(void);
36 36 extern _PyInitError _PySys_Create(
37 +_PyRuntimeState *runtime,
37 38 PyInterpreterState *interp,
38 39 PyObject **sysmod_p);
39 40 extern _PyInitError _PySys_SetPreliminaryStderr(PyObject *sysdict);
40 -extern int _PySys_InitMain(PyInterpreterState *interp);
41 +extern int _PySys_InitMain(
42 +_PyRuntimeState *runtime,
43 +PyInterpreterState *interp);
41 44 extern _PyInitError _PyImport_Init(PyInterpreterState *interp);
42 45 extern _PyInitError _PyExc_Init(void);
43 46 extern _PyInitError _PyBuiltins_AddExceptions(PyObject * bltinmod);
@@ -74,7 +77,10 @@ extern void _PyFaulthandler_Fini(void);
74 77 extern void _PyHash_Fini(void);
75 78 extern int _PyTraceMalloc_Fini(void);
76 79
77 -extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
80 +extern void _PyGILState_Init(
81 +_PyRuntimeState *runtime,
82 +PyInterpreterState *interp,
83 +PyThreadState *tstate);
78 84 extern void _PyGILState_Fini(_PyRuntimeState *runtime);
79 85
80 86 PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);
Original file line number Diff line number Diff line change
@@ -1605,13 +1605,13 @@ config_init_stdio(const _PyCoreConfig *config)
1605 1605 - set Py_xxx global configuration variables
1606 1606 - initialize C standard streams (stdin, stdout, stderr) */
1607 1607 void
1608 -_PyCoreConfig_Write(const _PyCoreConfig *config)
1608 +_PyCoreConfig_Write(const _PyCoreConfig *config, _PyRuntimeState *runtime)
1609 1609 {
1610 1610 _PyCoreConfig_SetGlobalConfig(config);
1611 1611 config_init_stdio(config);
1612 1612
1613 1613 /* Write the new pre-configuration into _PyRuntime */
1614 -_PyPreConfig *preconfig = &_PyRuntime.preconfig;
1614 +_PyPreConfig *preconfig = &runtime->preconfig;
1615 1615 preconfig->isolated = config->isolated;
1616 1616 preconfig->use_environment = config->use_environment;
1617 1617 preconfig->dev_mode = config->dev_mode;