[PATCH 1 of 2] windows: open registry keys using unicode names
Matt Harbison
mharbison72 at gmail.com
Fri Sep 14 04:52:33 UTC 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1536886493 14400
# Thu Sep 13 20:54:53 2018 -0400
# Node ID 82be987da1489e3ff7411540b473690e6039fd67
# Parent 98e5168116983dfcac1a3b99169b9c0504778ac4
windows: open registry keys using unicode names
Python3 complained it must be str. While here, use a context manager to close
the key- it wouldn't wrap at 80 characters the old way, and would have had to
move anyway.
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -554,9 +554,10 @@ def lookupreg(key, valname=None, scope=N
scope = (scope,)
for s in scope:
try:
- val = winreg.QueryValueEx(winreg.OpenKey(s, key), valname)[0]
- # never let a Unicode string escape into the wild
- return encoding.unitolocal(val)
+ with winreg.OpenKey(s, encoding.unifromlocal(key)) as hkey:
+ val = winreg.QueryValueEx(hkey, valname)[0]
+ # never let a Unicode string escape into the wild
+ return encoding.unitolocal(val)
except EnvironmentError:
pass
More information about the Mercurial-devel
mailing list