pycodestyle: Do not use bare 'except:'

A bare 'except:' catches all exceptions [1], including SystemExit,
KeyboardInterrupt, and GeneratorExit (which is not an error and should
not normally be caught by user code). In situations where you need to
catch all “normal” errors, you can catch the base class for all normal
exceptions, Exception [2].

[1] https://docs.python.org/2/howto/doanddont.html#except
[2] https://docs.python.org/2/library/exceptions.html#Exception
This commit is contained in:
Radostin Stoyanov
2017-08-02 13:57:43 -04:00
committed by Cole Robinson
parent 2fd6d9aa32
commit b93cc3bbc9
60 changed files with 125 additions and 127 deletions
+3 -5
View File
@@ -422,7 +422,7 @@ class TestBaseCommand(distutils.core.Command):
try:
import coverage
use_cov = True
except:
except ImportError:
use_cov = False
cov = None
@@ -439,10 +439,8 @@ class TestBaseCommand(distutils.core.Command):
testsmodule.utils.REGENERATE_OUTPUT = bool(self.regenerate_output)
if hasattr(unittest, "installHandler"):
try:
unittest.installHandler()
except:
print("installHandler hack failed")
# Install the control-c handler.
unittest.installHandler()
tests = unittest.TestLoader().loadTestsFromNames(self._testfiles)
if self.only: