mercurial/util_win32.py
changeset 6880 892806b3fc0f
parent 6216 a88259018f79
child 6881 d2375bbee6d4
--- a/mercurial/util_win32.py	Thu Jul 31 22:41:19 2008 +0300
+++ b/mercurial/util_win32.py	Sun Aug 10 22:55:00 2008 -0500
@@ -201,21 +201,17 @@
     except ImportError:
         return None
 
-    def query_val(scope, key, valname):
-        try:
-            keyhandle = OpenKey(scope, key)
-            return QueryValueEx(keyhandle, valname)[0]
-        except EnvironmentError:
-            return None
-
     if scope is None:
         scope = (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE)
     elif not isinstance(scope, (list, tuple)):
         scope = (scope,)
     for s in scope:
-        val = query_val(s, key, valname)
-        if val is not None:
-            return val
+        try:
+            val = QueryValueEx(OpenKey(scope, key), valname)[0]
+            # never let a Unicode string escape into the wild
+            return util.tolocal(val.encode('UTF-8'))
+        except EnvironmentError:
+            pass
 
 def system_rcpath_win32():
     '''return default os-specific hgrc search path'''