New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong error caught in RegistryInfo.lookup #646

shortenda opened this Issue Jul 13, 2016 · 4 comments


None yet
3 participants

shortenda commented Jul 13, 2016


I believe that RegistryInfo.lookup should be except'ing WindowsError instead of IOError when it calls open key

I ran into this issue trying to install a package. Sorry if this isn't correct as I'm not familiar with this project.



This comment has been minimized.


jaraco commented Jul 14, 2016

What's the benefit of catching WindowsError instead of IOError? I see that WindowsError is a subclass of OSError, of which IOError is also a subclass on Python 3 (but apparently not Python 2).

What issue did you encounter? Is it possible there are conditions where a WindowsError might be raised, so perhaps multiple exceptions should be caught?


This comment has been minimized.

shortenda commented Jul 14, 2016

OpenKey throws a WindowsError if the registry key it's looking for can't be found in python2. So in python2, where WindowsError is distinct from and not a subclass of IOError, a lookup attempt on a missing registry key is not caught and crashes setuptools. In my case a missing visual studio registry key was stopping the install, whereas the intention was to fall back to a default.

It actually seems like it would be most prudent to catch EnvironmentError, apparently this is what winreg.OpenKey throws in python3 and would also catch WindowsError in python2.


This comment has been minimized.


jaraco commented Jul 28, 2016

@JGoutin Would you be willing to review? Do you concur with shortenda's analysis?


This comment has been minimized.


JGoutin commented Jul 28, 2016

On Python 3, if OpenKey don't found the key a FileNotFoundError is raised (subclass of IOError, FileNotFoundError is not available on Python 2). But, indeed, like wrote in the doc and said by shortenda, this function may also raise WindowsError (On Python 2) or OSError (On Python 3).

IOError have been merged in OSError only since Python 3.3.

So, to cover all case, we need to except OSError and IOError.

jaraco added a commit that referenced this issue Jul 30, 2016

Merge pull request #700 from JGoutin/patch-1
Fix for #646 : Wrong error caught in RegistryInfo.lookup

@shortenda shortenda closed this Apr 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment