mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-32030: Complete _PyCoreConfig_Read() (#4946)
* Add _PyCoreConfig.install_signal_handlers * Remove _PyMain.config: _PyMainInterpreterConfig usage is now restricted to pymain_init_python_main(). * Rename _PyMain.core_config to _PyMain.config * _PyMainInterpreterConfig_Read() now creates the xoptions dictionary from the core config * Fix _PyMainInterpreterConfig_Read(): don't replace xoptions and argv if they are already set.
This commit is contained in:
parent
51eb1c6b9c
commit
9cfc00262c
3 changed files with 387 additions and 346 deletions
|
@ -874,30 +874,29 @@ _Py_InitializeMainInterpreter(const _PyMainInterpreterConfig *config)
|
|||
_PyInitError
|
||||
_Py_InitializeEx_Private(int install_sigs, int install_importlib)
|
||||
{
|
||||
_PyCoreConfig core_config = _PyCoreConfig_INIT;
|
||||
_PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT;
|
||||
_PyCoreConfig config = _PyCoreConfig_INIT;
|
||||
_PyInitError err;
|
||||
|
||||
core_config.ignore_environment = Py_IgnoreEnvironmentFlag;
|
||||
core_config._disable_importlib = !install_importlib;
|
||||
config.ignore_environment = Py_IgnoreEnvironmentFlag;
|
||||
config._disable_importlib = !install_importlib;
|
||||
config.install_signal_handlers = install_sigs;
|
||||
|
||||
err = _PyCoreConfig_Read(&core_config);
|
||||
err = _PyCoreConfig_Read(&config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
err = _Py_InitializeCore(&core_config);
|
||||
err = _Py_InitializeCore(&config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
err = _PyMainInterpreterConfig_Read(&config, &core_config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
_PyMainInterpreterConfig main_config = _PyMainInterpreterConfig_INIT;
|
||||
err = _PyMainInterpreterConfig_Read(&main_config, &config);
|
||||
if (!_Py_INIT_FAILED(err)) {
|
||||
err = _Py_InitializeMainInterpreter(&main_config);
|
||||
}
|
||||
|
||||
err = _Py_InitializeMainInterpreter(&config);
|
||||
_PyMainInterpreterConfig_Clear(&main_config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -905,8 +904,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
|
|||
err = _Py_INIT_OK();
|
||||
|
||||
done:
|
||||
_PyCoreConfig_Clear(&core_config);
|
||||
_PyMainInterpreterConfig_Clear(&config);
|
||||
_PyCoreConfig_Clear(&config);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue