mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-36301: Add _PyRuntime.pre_initialized (GH-12457)
* Add _PyRuntime.pre_initialized: set to 1 when Python is pre-initialized * Add _Py_PreInitialize() and _Py_PreInitializeFromPreConfig(). * _PyCoreConfig_Read() now calls _Py_PreInitialize(). * Move _PyPreConfig_GetGlobalConfig() and _PyCoreConfig_GetGlobalConfig() calls from main.c to preconfig.c and coreconfig.c.
This commit is contained in:
parent
0d765e3849
commit
f29084d611
6 changed files with 77 additions and 27 deletions
|
|
@ -283,32 +283,30 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config,
|
|||
/* --- pymain_init() ---------------------------------------------- */
|
||||
|
||||
static _PyInitError
|
||||
preconfig_read_write(_PyPreConfig *config, const _PyArgv *args)
|
||||
pymain_init_preconfig(_PyPreConfig *config, const _PyArgv *args)
|
||||
{
|
||||
_PyPreConfig_GetGlobalConfig(config);
|
||||
|
||||
_PyInitError err = _PyPreConfig_ReadFromArgv(config, args);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return _PyPreConfig_Write(config);
|
||||
return _Py_PreInitializeFromPreConfig(config);
|
||||
}
|
||||
|
||||
|
||||
static _PyInitError
|
||||
config_read_write(_PyCoreConfig *config, const _PyArgv *args,
|
||||
const _PyPreConfig *preconfig)
|
||||
pymain_init_coreconfig(_PyCoreConfig *config, const _PyArgv *args,
|
||||
const _PyPreConfig *preconfig,
|
||||
PyInterpreterState **interp_p)
|
||||
{
|
||||
_PyCoreConfig_GetGlobalConfig(config);
|
||||
|
||||
_PyInitError err = _PyCoreConfig_ReadFromArgv(config, args, preconfig);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
}
|
||||
|
||||
_PyCoreConfig_Write(config);
|
||||
return _Py_INIT_OK();
|
||||
|
||||
return _Py_InitializeCore(interp_p, config);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -356,24 +354,17 @@ pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
|
|||
_PyCoreConfig local_config = _PyCoreConfig_INIT;
|
||||
_PyCoreConfig *config = &local_config;
|
||||
|
||||
err = preconfig_read_write(preconfig, args);
|
||||
err = pymain_init_preconfig(preconfig, args);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
err = config_read_write(config, args, preconfig);
|
||||
err = pymain_init_coreconfig(config, args, preconfig, interp_p);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
PyInterpreterState *interp;
|
||||
err = _Py_InitializeCore(&interp, config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
*interp_p = interp;
|
||||
|
||||
err = pymain_init_python_main(interp);
|
||||
err = pymain_init_python_main(*interp_p);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue