bpo-42260: Fix _PyConfig_Read() if compute_path_config=0 (GH-23220)

Fix _PyConfig_Read() if compute_path_config=0: use values set by
Py_SetPath(), Py_SetPythonHome() and Py_SetProgramName(). Add
compute_path_config parameter to _PyConfig_InitPathConfig().

The following functions now return NULL if called before
Py_Initialize():

* Py_GetExecPrefix()
* Py_GetPath()
* Py_GetPrefix()
* Py_GetProgramFullPath()
* Py_GetProgramName()
* Py_GetPythonHome()

These functions no longer automatically computes the Python Path
Configuration. Moreover, Py_SetPath() no longer computes
program_full_path.
This commit is contained in:
Victor Stinner 2020-11-10 21:10:22 +01:00 committed by GitHub
parent 1e996c3a3b
commit ace3f9a0ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 95 deletions

View file

@ -2069,8 +2069,8 @@ config_read(PyConfig *config, int compute_path_config)
}
}
if (compute_path_config && config->_install_importlib) {
status = _PyConfig_InitPathConfig(config);
if (config->_install_importlib) {
status = _PyConfig_InitPathConfig(config, compute_path_config);
if (_PyStatus_EXCEPTION(status)) {
return status;
}