Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apitools/base/py/credentials_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ def _CheckCacheFileForMatch(self, cache_filename, scopes):
if (creds['scopes'] in
(None, cached_creds['scopes'])):
scopes = cached_creds['scopes']
except KeyboardInterrupt:
raise
except: # pylint: disable=bare-except
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it not possible to list specific exceptions we care to skip. This would also supress Ctrl-C.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, do you have any other suggestions beyond KeyboardInterrupt?

# Treat exceptions as a cache miss.
pass
finally:
cache_file.unlock_and_close()
return scopes
Expand Down Expand Up @@ -331,6 +336,11 @@ def _WriteCacheFile(self, cache_filename, scopes):
# If it's not locked, the locking process will
# write the same data to the file, so just
# continue.
except KeyboardInterrupt:
raise
except: # pylint: disable=bare-except
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we care to add any unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would require mocking locked_file which was removed from more recent versions of oauth2client; this code is simple enough that I'd prefer not to unless you object.

# Treat exceptions as a cache miss.
pass
finally:
cache_file.unlock_and_close()

Expand Down