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

6 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -8,6 +8,8 @@ extern "C" {

88

# error "this header requires Py_BUILD_CORE define"

99

#endif

1010
11+

#include "pycore_pystate.h" /* _PyRuntimeState */

12+
1113
1214

/* --- _PyWstrList ------------------------------------------------ */

1315

@@ -108,7 +110,8 @@ PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(

108110

const _PyCoreConfig *config);

109111

PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config,

110112

const _PyArgv *args);

111-

PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config);

113+

PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config,

114+

_PyRuntimeState *runtime);

112115
113116
114117

/* --- Function used for testing ---------------------------------- */

Original file line numberDiff line numberDiff line change

@@ -34,10 +34,13 @@ extern _PyInitError _PyFaulthandler_Init(int enable);

3434

extern int _PyTraceMalloc_Init(int enable);

3535

extern PyObject * _PyBuiltin_Init(void);

3636

extern _PyInitError _PySys_Create(

37+

_PyRuntimeState *runtime,

3738

PyInterpreterState *interp,

3839

PyObject **sysmod_p);

3940

extern _PyInitError _PySys_SetPreliminaryStderr(PyObject *sysdict);

40-

extern int _PySys_InitMain(PyInterpreterState *interp);

41+

extern int _PySys_InitMain(

42+

_PyRuntimeState *runtime,

43+

PyInterpreterState *interp);

4144

extern _PyInitError _PyImport_Init(PyInterpreterState *interp);

4245

extern _PyInitError _PyExc_Init(void);

4346

extern _PyInitError _PyBuiltins_AddExceptions(PyObject * bltinmod);

@@ -74,7 +77,10 @@ extern void _PyFaulthandler_Fini(void);

7477

extern void _PyHash_Fini(void);

7578

extern int _PyTraceMalloc_Fini(void);

7679
77-

extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);

80+

extern void _PyGILState_Init(

81+

_PyRuntimeState *runtime,

82+

PyInterpreterState *interp,

83+

PyThreadState *tstate);

7884

extern void _PyGILState_Fini(_PyRuntimeState *runtime);

7985
8086

PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);

Original file line numberDiff line numberDiff line change

@@ -1605,13 +1605,13 @@ config_init_stdio(const _PyCoreConfig *config)

16051605

- set Py_xxx global configuration variables

16061606

- initialize C standard streams (stdin, stdout, stderr) */

16071607

void

1608-

_PyCoreConfig_Write(const _PyCoreConfig *config)

1608+

_PyCoreConfig_Write(const _PyCoreConfig *config, _PyRuntimeState *runtime)

16091609

{

16101610

_PyCoreConfig_SetGlobalConfig(config);

16111611

config_init_stdio(config);

16121612
16131613

/* Write the new pre-configuration into _PyRuntime */

1614-

_PyPreConfig *preconfig = &_PyRuntime.preconfig;

1614+

_PyPreConfig *preconfig = &runtime->preconfig;

16151615

preconfig->isolated = config->isolated;

16161616

preconfig->use_environment = config->use_environment;

16171617

preconfig->dev_mode = config->dev_mode;