]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
On windows, os.chdir given unicode was not working if GetCurrentDirectoryW
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Thu, 9 Oct 2008 10:00:30 +0000 (10:00 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Thu, 9 Oct 2008 10:00:30 +0000 (10:00 +0000)
returned a path longer than MAX_PATH. (But It's doubtful this code path is
really executed because I cannot move to such directory on win2k)

Misc/NEWS
Modules/posixmodule.c

index dc435542d42ac20e71805fd237738242b3e6a998..dc191d64fec09dcee5c3e31b3ecb6f13ea546f7d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.7 alpha 1
 Core and Builtins
 -----------------
 
+- On windows, os.chdir given unicode was not working if GetCurrentDirectoryW
+  returned a path longer than MAX_PATH. (But It's doubtful this code path is
+  really executed because I cannot move to such directory on win2k)
+
 - Issue #4069: When set.remove(element) is used with a set element, the element
   is temporarily replaced with an equivalent frozenset.  But the eventual
   KeyError would always report the empty frozenset([]) as the missing key. Now
index 79c3a4437d1e89b02c3a684c67d47076d50a0170..6e4925b5f5729a4be3c013ba0180ea9353186f65 100644 (file)
@@ -726,11 +726,14 @@ win32_wchdir(LPCWSTR path)
        if (!result)
                return FALSE;
        if (result > MAX_PATH+1) {
-               new_path = malloc(result);
+               new_path = malloc(result * sizeof(wchar_t));
                if (!new_path) {
                        SetLastError(ERROR_OUTOFMEMORY);
                        return FALSE;
                }
+               result = GetCurrentDirectoryW(result, new_path);
+               if (!result)
+                       return FALSE;
        }
        if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
            wcsncmp(new_path, L"//", 2) == 0)