summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-25 16:54:58 (GMT)
committerGitHub <noreply@github.com>2019-03-25 16:54:58 (GMT)
commitf72346c47537657a287a862305f65eb5d7594fbf (patch)
treed97a19e2a156c04623bcefd32a16b851798a53af /Modules/main.c
parent68d228f174ceed151200e7e0b44ffc5edd4e0ea2 (diff)
downloadcpython-f72346c47537657a287a862305f65eb5d7594fbf.zip
cpython-f72346c47537657a287a862305f65eb5d7594fbf.tar.gz
cpython-f72346c47537657a287a862305f65eb5d7594fbf.tar.bz2
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.
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 57cf862..197c9b3 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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;
}