Patchwork [V2] py3: use str to query registry values on Windows

login
register
mail settings
Submitter Matt Harbison
Date Oct. 13, 2018, 5:44 p.m.
Message ID <83dab13d625cd3fa2ce2.1539452665@Envy>
Download mbox | patch
Permalink /patch/35943/
State Accepted
Headers show

Comments

Matt Harbison - Oct. 13, 2018, 5:44 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1539380085 14400
#      Fri Oct 12 17:34:45 2018 -0400
# Node ID 83dab13d625cd3fa2ce24801c9ee962d695045b8
# Parent  d6b7c4e77bb414fa27fed41e834423fca7d6ce63
py3: use str to query registry values on Windows

This blew up launching any command if extdiff processed a tool with a regkey
config.
Yuya Nishihara - Oct. 14, 2018, 4:35 a.m.
On Sat, 13 Oct 2018 13:44:25 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1539380085 14400
> #      Fri Oct 12 17:34:45 2018 -0400
> # Node ID 83dab13d625cd3fa2ce24801c9ee962d695045b8
> # Parent  d6b7c4e77bb414fa27fed41e834423fca7d6ce63
> py3: use str to query registry values on Windows

Queued, thanks.

Patch

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -583,7 +583,8 @@  def lookupreg(key, valname=None, scope=N
     for s in scope:
         try:
             with winreg.OpenKey(s, encoding.strfromlocal(key)) as hkey:
-                val = winreg.QueryValueEx(hkey, valname)[0]
+                name = valname and encoding.strfromlocal(valname) or valname
+                val = winreg.QueryValueEx(hkey, name)[0]
                 # never let a Unicode string escape into the wild
                 return encoding.unitolocal(val)
         except EnvironmentError: