-
Notifications
You must be signed in to change notification settings - Fork 30
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
Handle file not found exceptions on Python 2.7 #69
Conversation
Thanks for the finding! How urgent is this? We have been working on some relevant PRs here, and could cut a release within a week or two. Will that work? |
There are workarounds but it affects our core getting started scenario, so one week is much better than two. Will the release be 0.2.3? |
Well then, let's aim for a release with this fix at no later than next Monday (that is one week). PR wise, it would be better to see some test case(s) to guard a potential future regression. If Charles can provide some, it would be great; otherwise @abhidnya13 and I will still pick this up within next couple days. |
Thanks @chlowell for the code snippet. I created a branch to add a test case for this.
|
@abhidnya13 Thanks very much for the before-and-after comparison! Either creating a new PR (and linking back to this one), or adding your test case to this PR. They are both good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test case for this bug. The change looks good to me ! Thanks Charles !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good collaboration! Merging.
On Python 3, calling
PersistedTokenCache.find()
on a nonexistent cache file is a no-op, so this code works:On Python 2.7 it raises a platform-specific error:
WindowsError
on Windows,OSError
on Linux (I haven't tried it on macOS). The difference in behavior is due toPersistedTokenCache
anticipatingIOError
when a file isn't found. NeitherWindowsError
norOSError
is a subclass ofIOError
. All these errors are subclasses ofEnvironmentError
though, and that class has theerrno
attribute, so a simple fix is to handleEnvironmentError
here.