mirror of
https://github.com/python/cpython
synced 2024-09-05 16:38:56 +00:00
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).
This commit is contained in:
parent
77af2290e5
commit
e267793aa4
|
@ -0,0 +1,2 @@
|
||||||
|
Python ignored path passed to :c:func:`Py_SetPath`, fix Python
|
||||||
|
initialization to use the specified path.
|
|
@ -1213,10 +1213,12 @@ calculate_path_impl(const PyConfig *config,
|
||||||
"Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n");
|
"Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
status = calculate_module_search_path(config, calculate,
|
if (pathconfig->module_search_path == NULL) {
|
||||||
prefix, exec_prefix, pathconfig);
|
status = calculate_module_search_path(config, calculate,
|
||||||
if (_PyStatus_EXCEPTION(status)) {
|
prefix, exec_prefix, pathconfig);
|
||||||
return status;
|
if (_PyStatus_EXCEPTION(status)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = calculate_reduce_prefix(calculate, prefix, Py_ARRAY_LENGTH(prefix));
|
status = calculate_reduce_prefix(calculate, prefix, Py_ARRAY_LENGTH(prefix));
|
||||||
|
|
|
@ -1003,9 +1003,12 @@ calculate_path_impl(const PyConfig *config,
|
||||||
|
|
||||||
calculate_home_prefix(calculate, prefix);
|
calculate_home_prefix(calculate, prefix);
|
||||||
|
|
||||||
status = calculate_module_search_path(config, calculate, pathconfig, prefix);
|
if (pathconfig->module_search_path == NULL) {
|
||||||
if (_PyStatus_EXCEPTION(status)) {
|
status = calculate_module_search_path(config, calculate,
|
||||||
return status;
|
pathconfig, prefix);
|
||||||
|
if (_PyStatus_EXCEPTION(status)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -74,6 +74,13 @@ pathconfig_calculate(_PyPathConfig *pathconfig, const PyConfig *config)
|
||||||
PyMemAllocatorEx old_alloc;
|
PyMemAllocatorEx old_alloc;
|
||||||
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
||||||
|
|
||||||
|
if (copy_wstr(&new_config.module_search_path,
|
||||||
|
_Py_path_config.module_search_path) < 0)
|
||||||
|
{
|
||||||
|
status = _PyStatus_NO_MEMORY();
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate program_full_path, prefix, exec_prefix,
|
/* Calculate program_full_path, prefix, exec_prefix,
|
||||||
dll_path (Windows), and module_search_path */
|
dll_path (Windows), and module_search_path */
|
||||||
status = _PyPathConfig_Calculate(&new_config, config);
|
status = _PyPathConfig_Calculate(&new_config, config);
|
||||||
|
|
Loading…
Reference in a new issue