Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Python ignored path passed to :c:func:`Py_SetPath`, fix Python
initialization to use the specified path.
10 changes: 6 additions & 4 deletions Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,10 +1213,12 @@ calculate_path_impl(const PyConfig *config,
"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));
Expand Down
9 changes: 6 additions & 3 deletions PC/getpathp.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,12 @@ calculate_path_impl(const PyConfig *config,

calculate_home_prefix(calculate, prefix);

status = calculate_module_search_path(config, calculate, pathconfig, prefix);
if (_PyStatus_EXCEPTION(status)) {
return status;
if (pathconfig->module_search_path == NULL) {
status = calculate_module_search_path(config, calculate,
pathconfig, prefix);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
}

done:
Expand Down
7 changes: 7 additions & 0 deletions Python/pathconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ pathconfig_calculate(_PyPathConfig *pathconfig, const PyConfig *config)
PyMemAllocatorEx 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,
dll_path (Windows), and module_search_path */
status = _PyPathConfig_Calculate(&new_config, config);
Expand Down