# HG changeset patch # User Yuya Nishihara # Date 1514862848 -32400 # Node ID ed30934165c91c3438afa3ab347abfb605a68a92 # Parent 94a127152e2576ce11c56fba7fa3b6f870811d96 win32: do not call GetVolumePathName() with the minimum buffer length It fails on Windows XP even though the doc says "a safer but slower way to set the size of the return buffer is to call the GetFullPathName function, and then make sure that the buffer size is at least the same size as the full path that GetFullPathName returns." https://msdn.microsoft.com/en-us/library/windows/desktop/aa364996(v=vs.85).aspx Well, more "safe" way would be to simply rely on MAX_PATH for common scenarios. diff -r 94a127152e25 -r ed30934165c9 mercurial/win32.py --- a/mercurial/win32.py Tue Jan 02 12:02:25 2018 +0900 +++ b/mercurial/win32.py Tue Jan 02 12:14:08 2018 +0900 @@ -439,7 +439,9 @@ # realpath() calls GetFullPathName() realpath = os.path.realpath(path) - size = len(realpath) + 1 + # allocate at least MAX_PATH long since GetVolumePathName('c:\\', buf, 4) + # somehow fails on Windows XP + size = max(len(realpath), _MAX_PATH) + 1 buf = ctypes.create_string_buffer(size) if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size):