mirror of https://github.com/python/cpython
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
|
@ -25,6 +25,7 @@ typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int);
|
|||
|
||||
|
||||
typedef struct {
|
||||
int install_signal_handlers; /* Install signal handlers? -1 means unset */
|
||||
int ignore_environment; /* -E */
|
||||
int use_hash_seed; /* PYTHONHASHSEED=x */
|
||||
unsigned long hash_seed;
|
||||
|
@ -62,6 +63,7 @@ typedef struct {
|
|||
|
||||
#define _PyCoreConfig_INIT \
|
||||
(_PyCoreConfig){ \
|
||||
.install_signal_handlers = -1, \
|
||||
.use_hash_seed = -1, \
|
||||
.coerce_c_locale = -1, \
|
||||
.utf8_mode = -1, \
|
||||
|
@ -73,7 +75,7 @@ typedef struct {
|
|||
* See PEP 432 for final anticipated contents
|
||||
*/
|
||||
typedef struct {
|
||||
int install_signal_handlers;
|
||||
int install_signal_handlers; /* Install signal handlers? -1 means unset */
|
||||
PyObject *argv; /* sys.argv list, can be NULL */
|
||||
PyObject *executable; /* sys.executable str */
|
||||
PyObject *prefix; /* sys.prefix str */
|
||||
|
|
705
Modules/main.c
705
Modules/main.c
File diff suppressed because it is too large
Load Diff
|
@ -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…
Reference in New Issue