Mercurial > hg
comparison mercurial/windows.py @ 39643:47ac5d93d708
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.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 13 Sep 2018 20:54:53 -0400 |
parents | c382c19ce9bd |
children | 3b421154d2ca |
comparison
equal
deleted
inserted
replaced
39642:a407f9009392 | 39643:47ac5d93d708 |
---|---|
552 scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE) | 552 scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE) |
553 elif not isinstance(scope, (list, tuple)): | 553 elif not isinstance(scope, (list, tuple)): |
554 scope = (scope,) | 554 scope = (scope,) |
555 for s in scope: | 555 for s in scope: |
556 try: | 556 try: |
557 val = winreg.QueryValueEx(winreg.OpenKey(s, key), valname)[0] | 557 with winreg.OpenKey(s, encoding.strfromlocal(key)) as hkey: |
558 # never let a Unicode string escape into the wild | 558 val = winreg.QueryValueEx(hkey, valname)[0] |
559 return encoding.unitolocal(val) | 559 # never let a Unicode string escape into the wild |
560 return encoding.unitolocal(val) | |
560 except EnvironmentError: | 561 except EnvironmentError: |
561 pass | 562 pass |
562 | 563 |
563 expandglobs = True | 564 expandglobs = True |
564 | 565 |