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

@ -1039,7 +1039,7 @@ init_interp_main(PyThreadState *tstate)
}
// Compute the path configuration
status = _PyConfig_InitPathConfig(&interp->config);
status = _PyConfig_InitPathConfig(&interp->config, 1);
if (_PyStatus_EXCEPTION(status)) {
return status;
}