From 64c5e817723df441d40f00f0b7b35f873ffb6b7f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 19 Aug 2019 14:51:35 -0700 Subject: [PATCH] [windows] Replace python2-specific error handling with a check that works in python3 as well (#300) Fixes #298 --- emsdk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emsdk b/emsdk index aac263a..82d7a0e 100755 --- a/emsdk +++ b/emsdk @@ -268,7 +268,7 @@ def win_set_environment_variable_direct(key, value, system=True): win32api.RegSetValueEx(folder, key, 0, win32con.REG_EXPAND_SZ, value) if VERBOSE: print('Set key=' + key + ' with value ' + value + ' in registry.') except Exception as e: - if e[0] == 5 or e[2] == 'Access is denied.': + if e.args[0] == 5: # 'Access is denied.' print('Error! Failed to set the environment variable \'' + key + '\'! Setting environment variables permanently requires administrator access. Please rerun this command with administrative privileges. This can be done for example by holding down the Ctrl and Shift keys while opening a command prompt in start menu.') sys.exit(1) print('Failed to write environment variable ' + key + ':', file=sys.stderr) @@ -302,7 +302,7 @@ def win_get_environment_variable(key, system=True): # need to be precise not to set these back to system registry, or expansion items would be lost. return os.environ[key] except Exception as e: - if e[0] != 2: # 'The system cannot find the file specified.' + if e.args[0] != 2: # 'The system cannot find the file specified.' print('Failed to read environment variable ' + key + ':', file=sys.stderr) print(str(e), file=sys.stderr) try: