diff options
author | Matthias Hoelzl <tc@xantira.com> | 2017-10-29 17:55:05 +0100 |
---|---|---|
committer | Matthias Hoelzl <tc@xantira.com> | 2017-10-29 19:27:12 +0100 |
commit | a6d53effa5995cc8af995c5a7d80a4a9abc15b7c (patch) | |
tree | b11bf1cda08237f3b5faaa81d4541105e531c91d /modules/mono/mono_reg_utils.py | |
parent | 277e730d34633fac2427f216b53a16fb1641733e (diff) |
Fix build with Python 3 on Windows
Diffstat (limited to 'modules/mono/mono_reg_utils.py')
-rw-r--r-- | modules/mono/mono_reg_utils.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/mono/mono_reg_utils.py b/modules/mono/mono_reg_utils.py index 22c4aeaf4c..8ddddb3a24 100644 --- a/modules/mono/mono_reg_utils.py +++ b/modules/mono/mono_reg_utils.py @@ -1,6 +1,8 @@ import os import platform +from compat import decode_utf8 + if os.name == 'nt': import sys if sys.version_info < (3,): @@ -12,7 +14,7 @@ if os.name == 'nt': def _reg_open_key(key, subkey): try: return winreg.OpenKey(key, subkey) - except WindowsError, OSError: + except (WindowsError, OSError): if platform.architecture()[0] == '32bit': bitness_sam = winreg.KEY_WOW64_64KEY else: @@ -40,7 +42,7 @@ def _find_mono_in_reg(subkey, bits): with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey: value, regtype = winreg.QueryValueEx(hKey, 'SdkInstallRoot') return value - except WindowsError, OSError: + except (WindowsError, OSError): return None @@ -79,7 +81,7 @@ def find_msbuild_tools_path_reg(): lines = subprocess.check_output([vswhere] + vswhere_args).splitlines() for line in lines: - parts = line.split(':', 1) + parts = decode_utf8(line).split(':', 1) if len(parts) < 2 or parts[0] != 'installationPath': continue @@ -96,7 +98,7 @@ def find_msbuild_tools_path_reg(): print('Error reading output from vswhere: ' + e.message) except WindowsError: pass # Fine, vswhere not found - except subprocess.CalledProcessError, OSError: + except (subprocess.CalledProcessError, OSError): pass # Try to find 14.0 in the Registry @@ -106,7 +108,7 @@ def find_msbuild_tools_path_reg(): with _reg_open_key(winreg.HKEY_LOCAL_MACHINE, subkey) as hKey: value, regtype = winreg.QueryValueEx(hKey, 'MSBuildToolsPath') return value - except WindowsError, OSError: + except (WindowsError, OSError): return '' return '' |