diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py --- a/mercurial/scmwindows.py +++ b/mercurial/scmwindows.py @@ -52,7 +52,11 @@ # next look for a system rcpath in the registry value = util.lookupreg( - b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE + # pytype: disable=module-attr + b'SOFTWARE\\Mercurial', + None, + winreg.HKEY_LOCAL_MACHINE + # pytype: enable=module-attr ) if value and isinstance(value, bytes): value = util.localpath(value) diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -676,14 +676,21 @@ LOCAL_MACHINE). """ if scope is None: + # pytype: disable=module-attr scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE) + # pytype: enable=module-attr elif not isinstance(scope, (list, tuple)): scope = (scope,) for s in scope: try: + # pytype: disable=module-attr with winreg.OpenKey(s, encoding.strfromlocal(key)) as hkey: + # pytype: enable=module-attr name = valname and encoding.strfromlocal(valname) or valname + # pytype: disable=module-attr val = winreg.QueryValueEx(hkey, name)[0] + # pytype: enable=module-attr + # never let a Unicode string escape into the wild return encoding.unitolocal(val) except EnvironmentError: