Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2158231

Browse files
author
Victor Stinner
committed
Issue #6011: getpath: decode VPATH env var from the locale encoding
Instead of casting it to wchar_t* without conversion. It fixes a bug if Python is compiled a non-ascii directory, different than the source code directory, with C locale.
1 parent ff150f2 commit 2158231

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

Modules/getpath.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,16 @@ search_for_prefix(wchar_t *argv0_path, wchar_t *home)
285285
joinpath(prefix, L"Modules/Setup");
286286
if (isfile(prefix)) {
287287
/* Check VPATH to see if argv0_path is in the build directory. */
288-
vpath = L"" VPATH;
289-
wcscpy(prefix, argv0_path);
290-
joinpath(prefix, vpath);
291-
joinpath(prefix, L"Lib");
292-
joinpath(prefix, LANDMARK);
293-
if (ismodule(prefix))
294-
return -1;
288+
vpath = _Py_char2wchar(VPATH, NULL);
289+
if (vpath != NULL) {
290+
wcscpy(prefix, argv0_path);
291+
joinpath(prefix, vpath);
292+
PyMem_Free(vpath);
293+
joinpath(prefix, L"Lib");
294+
joinpath(prefix, LANDMARK);
295+
if (ismodule(prefix))
296+
return -1;
297+
}
295298
}
296299

297300
/* Search from argv0_path, until root is found */

0 commit comments

Comments
 (0)