mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-36301: Cleanup preconfig code (GH-12535)
Prepare code to move some _PyPreConfig parameters into _PyPreCmdline. Changes: * _PyCoreConfig_ReadFromArgv(): remove preconfig parameter, use _PyRuntime.preconfig. * Add _PyPreCmdline_GetPreConfig() (called by _PyPreConfig_Read()). * Rename _PyPreCmdline_Init() to _PyPreCmdline_SetArgv() * Factorize _Py_PreInitializeFromPreConfig() code: add pyinit_preinit(). * _PyPreConfig_Read() now sets coerce_c_locale to 2 if it must be coerced. * Remove _PyCoreConfig_ReadPreConfig(). * _PyCoreConfig_Write() now copies updated preconfig into _PyRuntime.
This commit is contained in:
parent
68d228f174
commit
f72346c475
7 changed files with 153 additions and 188 deletions
|
|
@ -283,28 +283,38 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config,
|
|||
/* --- pymain_init() ---------------------------------------------- */
|
||||
|
||||
static _PyInitError
|
||||
pymain_init_preconfig(_PyPreConfig *config, const _PyArgv *args)
|
||||
pymain_init_preconfig(const _PyArgv *args)
|
||||
{
|
||||
_PyInitError err = _PyPreConfig_ReadFromArgv(config, args);
|
||||
_PyInitError err;
|
||||
|
||||
_PyPreConfig config = _PyPreConfig_INIT;
|
||||
|
||||
err = _PyPreConfig_ReadFromArgv(&config, args);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
goto done;
|
||||
}
|
||||
|
||||
return _Py_PreInitializeFromPreConfig(config);
|
||||
err = _Py_PreInitializeFromPreConfig(&config);
|
||||
|
||||
done:
|
||||
_PyPreConfig_Clear(&config);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static _PyInitError
|
||||
pymain_init_coreconfig(_PyCoreConfig *config, const _PyArgv *args,
|
||||
const _PyPreConfig *preconfig,
|
||||
PyInterpreterState **interp_p)
|
||||
{
|
||||
_PyInitError err = _PyCoreConfig_ReadFromArgv(config, args, preconfig);
|
||||
_PyInitError err = _PyCoreConfig_ReadFromArgv(config, args);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
}
|
||||
|
||||
_PyCoreConfig_Write(config);
|
||||
err = _PyCoreConfig_Write(config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return _Py_InitializeCore(interp_p, config);
|
||||
}
|
||||
|
|
@ -348,18 +358,14 @@ pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
|
|||
fedisableexcept(FE_OVERFLOW);
|
||||
#endif
|
||||
|
||||
_PyPreConfig local_preconfig = _PyPreConfig_INIT;
|
||||
_PyPreConfig *preconfig = &local_preconfig;
|
||||
|
||||
_PyCoreConfig local_config = _PyCoreConfig_INIT;
|
||||
_PyCoreConfig *config = &local_config;
|
||||
|
||||
err = pymain_init_preconfig(preconfig, args);
|
||||
err = pymain_init_preconfig(args);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
return err;
|
||||
}
|
||||
|
||||
err = pymain_init_coreconfig(config, args, preconfig, interp_p);
|
||||
_PyCoreConfig config = _PyCoreConfig_INIT;
|
||||
|
||||
err = pymain_init_coreconfig(&config, args, interp_p);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -372,8 +378,7 @@ pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
|
|||
err = _Py_INIT_OK();
|
||||
|
||||
done:
|
||||
_PyPreConfig_Clear(preconfig);
|
||||
_PyCoreConfig_Clear(config);
|
||||
_PyCoreConfig_Clear(&config);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue