win32: remove try-catch block of GetModuleFileNameEx (issue2480) stable
authorYuya Nishihara <yuya@tcha.org>
Thu, 11 Nov 2010 01:12:51 +0900
branchstable
changeset 12966 5f80f44d23c5
parent 12965 0d4fb319974b
child 12967 70b043405400
win32: remove try-catch block of GetModuleFileNameEx (issue2480) According to the API document, GetModuleFileName is the preferred way to retrieve the filename of the current process. So we shouldn't try GetModuleFileName'Ex' first. Previously system_rcpath_win32() happened to return unicode paths due to GetModuleFileNameEx (issue2480). This problem is fixed as GetModuleFileName never return unicode.
mercurial/win32.py
--- a/mercurial/win32.py	Tue Nov 09 20:25:56 2010 +0000
+++ b/mercurial/win32.py	Thu Nov 11 01:12:51 2010 +0900
@@ -102,12 +102,7 @@
 
 def system_rcpath_win32():
     '''return default os-specific hgrc search path'''
-    proc = win32api.GetCurrentProcess()
-    try:
-        # This will fail on windows < NT
-        filename = win32process.GetModuleFileNameEx(proc, 0)
-    except:
-        filename = win32api.GetModuleFileName(0)
+    filename = win32api.GetModuleFileName(0)
     # Use mercurial.ini found in directory with hg.exe
     progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
     if os.path.isfile(progrc):