bpo-36301: Remove _PyCoreConfig.preconfig (GH-12546)

* Replace _PyCoreConfig.preconfig with 3 new fields in _PyCoreConfig:
  isolated, use_environment, dev_mode.
* Add _PyPreCmdline.dev_mode.
* Add _Py_PreInitializeFromPreConfigInPlace().
This commit is contained in:
Victor Stinner 2019-03-26 02:31:11 +01:00 committed by GitHub
parent f78a5e9ce8
commit 20004959d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 179 additions and 145 deletions

View file

@ -294,7 +294,7 @@ pymain_init_preconfig(const _PyArgv *args)
goto done;
}
err = _Py_PreInitializeFromPreConfig(&config);
err = _Py_PreInitializeInPlace(&config);
done:
_PyPreConfig_Clear(&config);
@ -311,11 +311,6 @@ pymain_init_coreconfig(_PyCoreConfig *config, const _PyArgv *args,
return err;
}
err = _PyCoreConfig_Write(config);
if (_Py_INIT_FAILED(err)) {
return err;
}
return _Py_InitializeCore(interp_p, config);
}
@ -483,7 +478,7 @@ pymain_header(const _PyCoreConfig *config)
static void
pymain_import_readline(const _PyCoreConfig *config)
{
if (config->preconfig.isolated) {
if (config->isolated) {
return;
}
if (!config->inspect && RUN_CODE(config)) {
@ -655,7 +650,7 @@ pymain_run_file(_PyCoreConfig *config, PyCompilerFlags *cf)
static void
pymain_run_startup(_PyCoreConfig *config, PyCompilerFlags *cf)
{
const char *startup = _Py_GetEnv(config->preconfig.use_environment, "PYTHONSTARTUP");
const char *startup = _Py_GetEnv(config->use_environment, "PYTHONSTARTUP");
if (startup == NULL) {
return;
}
@ -735,7 +730,7 @@ pymain_repl(_PyCoreConfig *config, PyCompilerFlags *cf, int *exitcode)
{
/* Check this environment variable at the end, to give programs the
opportunity to set it from Python. */
if (!Py_InspectFlag && _Py_GetEnv(config->preconfig.use_environment, "PYTHONINSPECT")) {
if (!Py_InspectFlag && _Py_GetEnv(config->use_environment, "PYTHONINSPECT")) {
Py_InspectFlag = 1;
config->inspect = 1;
}
@ -775,7 +770,7 @@ pymain_run_python(PyInterpreterState *interp, int *exitcode)
goto done;
}
}
else if (!config->preconfig.isolated) {
else if (!config->isolated) {
PyObject *path0 = NULL;
if (_PyPathConfig_ComputeSysPath0(&config->argv, &path0)) {
if (path0 == NULL) {