Index: pylib/gyp/MSVSVersion.py |
diff --git a/pylib/gyp/MSVSVersion.py b/pylib/gyp/MSVSVersion.py |
index edaf6eed001847ca5aff192ceab1d1ec4d75705a..bdbba9867b1ed637f4eb76b43aba3b8fb90a83e8 100644 |
--- a/pylib/gyp/MSVSVersion.py |
+++ b/pylib/gyp/MSVSVersion.py |
@@ -168,7 +168,7 @@ def _RegistryQuery(key, value=None): |
text = None |
try: |
text = _RegistryQueryBase('Sysnative', key, value) |
- except OSError, e: |
+ except OSError as e: |
if e.errno == errno.ENOENT: |
text = _RegistryQueryBase('System32', key, value) |
else: |
@@ -186,12 +186,15 @@ def _RegistryGetValueUsingWinReg(key, value): |
contents of the registry key's value, or None on failure. Throws |
ImportError if _winreg is unavailable. |
""" |
- import _winreg |
+ try: |
+ import _winreg as winreg |
+ except ImportError: |
+ import winreg |
try: |
root, subkey = key.split('\\', 1) |
assert root == 'HKLM' # Only need HKLM for now. |
- with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey: |
- return _winreg.QueryValueEx(hkey, value)[0] |
+ with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, subkey) as hkey: |
+ return winreg.QueryValueEx(hkey, value)[0] |
except WindowsError: |
return None |