summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2020-02-12 15:40:47 +0900
committerDavid Pursehouse <dpursehouse@collab.net>2020-02-12 06:49:25 +0000
commit145e35b805957487601514481df23b8fb723be38 (patch)
treed8d932f32782e485d9b95fb4d104d1427bce5981
parent819827a42ddb364f98c3a1a7eae2536dc54bc4cc (diff)
downloadgit-repo-145e35b805957487601514481df23b8fb723be38.tar.gz
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>
-rwxr-xr-xmain.py6
-rw-r--r--project.py4
-rw-r--r--subcmds/sync.py2
3 files changed, 6 insertions, 6 deletions
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):
364 req.add_header = _add_header 364 req.add_header = _add_header
365 return urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed( 365 return urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed(
366 self, authreq, host, req, headers) 366 self, authreq, host, req, headers)
367 except: 367 except Exception:
368 reset = getattr(self, 'reset_retry_count', None) 368 reset = getattr(self, 'reset_retry_count', None)
369 if reset is not None: 369 if reset is not None:
370 reset() 370 reset()
@@ -389,7 +389,7 @@ class _DigestAuthHandler(urllib.request.HTTPDigestAuthHandler):
389 req.add_header = _add_header 389 req.add_header = _add_header
390 return urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed( 390 return urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed(
391 self, auth_header, host, req, headers) 391 self, auth_header, host, req, headers)
392 except: 392 except Exception:
393 reset = getattr(self, 'reset_retry_count', None) 393 reset = getattr(self, 'reset_retry_count', None)
394 if reset is not None: 394 if reset is not None:
395 reset() 395 reset()
@@ -432,7 +432,7 @@ class _KerberosAuthHandler(urllib.request.BaseHandler):
432 return response 432 return response
433 except kerberos.GSSError: 433 except kerberos.GSSError:
434 return None 434 return None
435 except: 435 except Exception:
436 self.reset_retry_count() 436 self.reset_retry_count()
437 raise 437 raise
438 finally: 438 finally:
diff --git a/project.py b/project.py
index 372421cf..016f4a53 100644
--- a/project.py
+++ b/project.py
@@ -2619,7 +2619,7 @@ class Project(object):
2619 (self.worktree)): 2619 (self.worktree)):
2620 platform_utils.rmtree(platform_utils.realpath(self.worktree)) 2620 platform_utils.rmtree(platform_utils.realpath(self.worktree))
2621 return self._InitGitDir(mirror_git=mirror_git, force_sync=False) 2621 return self._InitGitDir(mirror_git=mirror_git, force_sync=False)
2622 except: 2622 except Exception:
2623 raise e 2623 raise e
2624 raise e 2624 raise e
2625 2625
@@ -2864,7 +2864,7 @@ class Project(object):
2864 try: 2864 try:
2865 platform_utils.rmtree(dotgit) 2865 platform_utils.rmtree(dotgit)
2866 return self._InitWorkTree(force_sync=False, submodules=submodules) 2866 return self._InitWorkTree(force_sync=False, submodules=submodules)
2867 except: 2867 except Exception:
2868 raise e 2868 raise e
2869 raise e 2869 raise e
2870 2870
diff --git a/subcmds/sync.py b/subcmds/sync.py
index c433ce6f..cc058af6 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -603,7 +603,7 @@ later is required to fix a server side protocol bug.
603 bare_git.gc('--auto', config=config) 603 bare_git.gc('--auto', config=config)
604 except GitError: 604 except GitError:
605 err_event.set() 605 err_event.set()
606 except: 606 except Exception:
607 err_event.set() 607 err_event.set()
608 raise 608 raise
609 finally: 609 finally: