]> granicus.if.org Git - python/commitdiff
Issue #6011: getpath: decode VPATH env var from the locale encoding
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 23 Oct 2010 00:13:28 +0000 (00:13 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 23 Oct 2010 00:13:28 +0000 (00:13 +0000)
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.

Modules/getpath.c

index 20030cecc6e4abe368746c1d88dfd48174e1a6b1..0d4a485c595f37817ab207af1430c9d5ec42db9a 100644 (file)
@@ -285,13 +285,16 @@ search_for_prefix(wchar_t *argv0_path, wchar_t *home)
     joinpath(prefix, L"Modules/Setup");
     if (isfile(prefix)) {
         /* Check VPATH to see if argv0_path is in the build directory. */
-        vpath = L"" VPATH;
-        wcscpy(prefix, argv0_path);
-        joinpath(prefix, vpath);
-        joinpath(prefix, L"Lib");
-        joinpath(prefix, LANDMARK);
-        if (ismodule(prefix))
-            return -1;
+        vpath = _Py_char2wchar(VPATH, NULL);
+        if (vpath != NULL) {
+            wcscpy(prefix, argv0_path);
+            joinpath(prefix, vpath);
+            PyMem_Free(vpath);
+            joinpath(prefix, L"Lib");
+            joinpath(prefix, LANDMARK);
+            if (ismodule(prefix))
+                return -1;
+        }
     }
 
     /* Search from argv0_path, until root is found */