mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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 <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
parent
819827a42d
commit
145e35b805
6
main.py
6
main.py
@ -364,7 +364,7 @@ class _BasicAuthHandler(urllib.request.HTTPBasicAuthHandler):
|
|||||||
req.add_header = _add_header
|
req.add_header = _add_header
|
||||||
return urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed(
|
return urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed(
|
||||||
self, authreq, host, req, headers)
|
self, authreq, host, req, headers)
|
||||||
except:
|
except Exception:
|
||||||
reset = getattr(self, 'reset_retry_count', None)
|
reset = getattr(self, 'reset_retry_count', None)
|
||||||
if reset is not None:
|
if reset is not None:
|
||||||
reset()
|
reset()
|
||||||
@ -389,7 +389,7 @@ class _DigestAuthHandler(urllib.request.HTTPDigestAuthHandler):
|
|||||||
req.add_header = _add_header
|
req.add_header = _add_header
|
||||||
return urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed(
|
return urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed(
|
||||||
self, auth_header, host, req, headers)
|
self, auth_header, host, req, headers)
|
||||||
except:
|
except Exception:
|
||||||
reset = getattr(self, 'reset_retry_count', None)
|
reset = getattr(self, 'reset_retry_count', None)
|
||||||
if reset is not None:
|
if reset is not None:
|
||||||
reset()
|
reset()
|
||||||
@ -432,7 +432,7 @@ class _KerberosAuthHandler(urllib.request.BaseHandler):
|
|||||||
return response
|
return response
|
||||||
except kerberos.GSSError:
|
except kerberos.GSSError:
|
||||||
return None
|
return None
|
||||||
except:
|
except Exception:
|
||||||
self.reset_retry_count()
|
self.reset_retry_count()
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
@ -2619,7 +2619,7 @@ class Project(object):
|
|||||||
(self.worktree)):
|
(self.worktree)):
|
||||||
platform_utils.rmtree(platform_utils.realpath(self.worktree))
|
platform_utils.rmtree(platform_utils.realpath(self.worktree))
|
||||||
return self._InitGitDir(mirror_git=mirror_git, force_sync=False)
|
return self._InitGitDir(mirror_git=mirror_git, force_sync=False)
|
||||||
except:
|
except Exception:
|
||||||
raise e
|
raise e
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
@ -2864,7 +2864,7 @@ class Project(object):
|
|||||||
try:
|
try:
|
||||||
platform_utils.rmtree(dotgit)
|
platform_utils.rmtree(dotgit)
|
||||||
return self._InitWorkTree(force_sync=False, submodules=submodules)
|
return self._InitWorkTree(force_sync=False, submodules=submodules)
|
||||||
except:
|
except Exception:
|
||||||
raise e
|
raise e
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ later is required to fix a server side protocol bug.
|
|||||||
bare_git.gc('--auto', config=config)
|
bare_git.gc('--auto', config=config)
|
||||||
except GitError:
|
except GitError:
|
||||||
err_event.set()
|
err_event.set()
|
||||||
except:
|
except Exception:
|
||||||
err_event.set()
|
err_event.set()
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user