[3.8] bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298) (GH-16313)
* bpo-38234: Remove _PyPathConfig.dll_path (GH-16307)
The DLL path is not computed from any user configuration and cannot
be configured by PyConfig. Instead, add a new _Py_dll_path global variable.
Remove _PyConfig_SetPathConfig(): replaced with _PyPathConfig_Init().
Py_Initialize() now longer sets the "global path configuration",
but only initialize _Py_dll_path.
(cherry picked from commit c422167749f92d4170203e996a2c619c818335ea)
* bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298)
* If Py_SetPath() has been called, _PyConfig_InitPathConfig() now
uses its value.
* Py_Initialize() now longer copies path configuration from PyConfig
to the global path configuration (_Py_path_config).
(cherry picked from commit e267793aa4101b2771ed0e66aaff5743d23f59af)
diff --git a/Modules/getpath.c b/Modules/getpath.c
index dc05748..5afb5b1 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -1213,10 +1213,12 @@
"Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n");
}
- status = calculate_module_search_path(config, calculate,
- prefix, exec_prefix, pathconfig);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
+ if (pathconfig->module_search_path == NULL) {
+ status = calculate_module_search_path(config, calculate,
+ prefix, exec_prefix, pathconfig);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
}
status = calculate_reduce_prefix(calculate, prefix, Py_ARRAY_LENGTH(prefix));