Skip to content

[windows] Replace python2-specific error handling with a string check that works in python3 as well - #300

Merged
kripken merged 3 commits into
masterfrom
win3
Aug 19, 2019
Merged

kripken merged 3 commits into
masterfrom
win3

Conversation

@kripken

@kripken kripken commented Jul 12, 2019

Copy link
Copy Markdown
Member

Fixes #298

Comment thread emsdk Outdated
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 'Access is denied.' in str(e):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work on non-English Windows systems (e.g. Russian):

Failed to write environment variable PATH:
(5, 'RegOpenKeyEx', 'Отказано в доступе.')

Similarly below. I still think using .args[0] is a better fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, thanks - the old code was doing that so I just assumed it was ok, but of course it isn't! :)

Ok, I changed it all to just use the code, and just using e.args.

@kripken

kripken commented Aug 19, 2019

Copy link
Copy Markdown
Member Author

review ping @jgravelle-google @sbc100

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the title of the PR seems wrong, perhaps it needs updating.

I don't much like reading this code.. but this doesn't seem to make it any worse.

@kripken
kripken merged commit 64c5e81 into master Aug 19, 2019
@kripken
kripken deleted the win3 branch August 19, 2019 21:51
vargaz pushed a commit to vargaz/emsdk that referenced this pull request Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

emsdk activate --global fails with Python 3 on Windows due to different KeyError behaviour

3 participants