bpo-36444: Add _PyCoreConfig._init_main (GH-12572)

* Add _PyCoreConfig._init_main: if equals to zero,
  _Py_InitializeFromConfig() doesn't call
  _Py_InitializeMainInterpreter().
* Add interp_p parameter to _Py_InitializeFromConfig().
* pymain_init() now calls _Py_InitializeFromConfig().
* Make _Py_InitializeCore() private.
This commit is contained in:
Victor Stinner 2019-03-27 02:04:16 +01:00 committed by GitHub
parent 8b9dbc017a
commit 484f20d2ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 46 deletions

View file

@ -53,19 +53,6 @@ done:
}
static _PyInitError
pymain_init_coreconfig(_PyCoreConfig *config, const _PyArgv *args,
PyInterpreterState **interp_p)
{
_PyInitError err = _PyCoreConfig_Read(config, args);
if (_Py_INIT_FAILED(err)) {
return err;
}
return _Py_InitializeCore(config, interp_p);
}
static _PyInitError
pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
{
@ -91,18 +78,22 @@ pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
}
_PyCoreConfig config = _PyCoreConfig_INIT;
err = pymain_init_coreconfig(&config, args, interp_p);
err = _PyCoreConfig_Read(&config, args);
if (_Py_INIT_FAILED(err)) {
goto done;
}
err = _Py_InitializeFromConfig(&config, interp_p);
if (_Py_INIT_FAILED(err)) {
goto done;
}
err = _Py_INIT_OK();
done:
_PyCoreConfig_Clear(&config);
if (_Py_INIT_FAILED(err)) {
return err;
}
err = _Py_InitializeMainInterpreter(*interp_p);
if (_Py_INIT_FAILED(err)) {
return err;
}
return _Py_INIT_OK();
return err;
}