File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -176,12 +176,18 @@ def _RegistryGetValueUsingWinReg(key, value):
176176 contents of the registry key's value, or None on failure. Throws
177177 ImportError if _winreg is unavailable.
178178 """
179- import _winreg
179+ try :
180+ # Python 2
181+ from _winreg import OpenKey , QueryValueEx
182+ except ImportError :
183+ # Python 3
184+ from winreg import OpenKey , QueryValueEx
185+
180186 try :
181187 root , subkey = key .split ('\\ ' , 1 )
182188 assert root == 'HKLM' # Only need HKLM for now.
183- with _winreg . OpenKey (_winreg .HKEY_LOCAL_MACHINE , subkey ) as hkey :
184- return _winreg . QueryValueEx (hkey , value )[0 ]
189+ with OpenKey (_winreg .HKEY_LOCAL_MACHINE , subkey ) as hkey :
190+ return QueryValueEx (hkey , value )[0 ]
185191 except WindowsError :
186192 return None
187193
You can’t perform that action at this time.
0 commit comments