From 145e35b805957487601514481df23b8fb723be38 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 12 Feb 2020 15:40:47 +0900 Subject: Fix usage of bare 'except' flake8 reports: E722 do not use bare 'except' Replace them with 'except Exception' per [1] which says: Bare except will catch exceptions you almost certainly don't want to catch, including KeyboardInterrupt (the user hitting Ctrl+C) and Python-raised errors like SystemExit If you don't have a specific exception you're expecting, at least except Exception, which is the base type for all "Regular" exceptions. [1] https://stackoverflow.com/a/54948581 Change-Id: Ic555ea9482645899f5b04040ddb6b24eadbf9062 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254606 Reviewed-by: Mike Frysinger Tested-by: David Pursehouse --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index d2a303ca..5f6bd81f 100755 --- a/main.py +++ b/main.py @@ -364,7 +364,7 @@ class _BasicAuthHandler(urllib.request.HTTPBasicAuthHandler): req.add_header = _add_header return urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed( self, authreq, host, req, headers) - except: + except Exception: reset = getattr(self, 'reset_retry_count', None) if reset is not None: reset() @@ -389,7 +389,7 @@ class _DigestAuthHandler(urllib.request.HTTPDigestAuthHandler): req.add_header = _add_header return urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed( self, auth_header, host, req, headers) - except: + except Exception: reset = getattr(self, 'reset_retry_count', None) if reset is not None: reset() @@ -432,7 +432,7 @@ class _KerberosAuthHandler(urllib.request.BaseHandler): return response except kerberos.GSSError: return None - except: + except Exception: self.reset_retry_count() raise finally: -- cgit v1.2.3-54-g00ecf