summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-20 01:20:13 (GMT)
committerGitHub <noreply@github.com>2019-03-20 01:20:13 (GMT)
commitf29084d611a6ca504c99a0967371374febf0ccc3 (patch)
tree4026d6cf02a675a3b34aa5e6b6d9e832cb1830a5 /Modules/main.c
parent0d765e3849f1010276bb349b557b79ed94befa0b (diff)
downloadcpython-f29084d611a6ca504c99a0967371374febf0ccc3.zip
cpython-f29084d611a6ca504c99a0967371374febf0ccc3.tar.gz
cpython-f29084d611a6ca504c99a0967371374febf0ccc3.tar.bz2
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.
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/Modules/main.c b/Modules/main.c
index df4eca5..57cf862 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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);
- if (_Py_INIT_FAILED(err)) {
- goto done;
- }
-
- PyInterpreterState *interp;
- err = _Py_InitializeCore(&interp, config);
+ err = pymain_init_coreconfig(config, args, preconfig, interp_p);
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;
}