Replace bare `except`s with `except BaseException`
Mostly I wanted to remove uses of `noqa`. In Python 3 the two are the same.
This commit is contained in:
parent
d1534181c0
commit
59a12e9ab3
|
@ -277,7 +277,7 @@ class TracebackEntry:
|
||||||
line = str(self.statement).lstrip()
|
line = str(self.statement).lstrip()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except: # noqa
|
except BaseException:
|
||||||
line = "???"
|
line = "???"
|
||||||
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
|
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
|
||||||
|
|
||||||
|
@ -667,12 +667,12 @@ class FormattedExcinfo:
|
||||||
s = str(source.getstatement(len(source) - 1))
|
s = str(source.getstatement(len(source) - 1))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except: # noqa
|
except BaseException:
|
||||||
try:
|
try:
|
||||||
s = str(source[-1])
|
s = str(source[-1])
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except: # noqa
|
except BaseException:
|
||||||
return 0
|
return 0
|
||||||
return 4 + (len(s) - len(s.lstrip()))
|
return 4 + (len(s) - len(s.lstrip()))
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ def wrap_session(
|
||||||
)
|
)
|
||||||
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
|
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
|
||||||
session.exitstatus = exitstatus
|
session.exitstatus = exitstatus
|
||||||
except: # noqa
|
except BaseException:
|
||||||
session.exitstatus = ExitCode.INTERNAL_ERROR
|
session.exitstatus = ExitCode.INTERNAL_ERROR
|
||||||
excinfo = _pytest._code.ExceptionInfo.from_current()
|
excinfo = _pytest._code.ExceptionInfo.from_current()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -123,7 +123,7 @@ class ApproxNumpy(ApproxBase):
|
||||||
if not np.isscalar(actual):
|
if not np.isscalar(actual):
|
||||||
try:
|
try:
|
||||||
actual = np.asarray(actual)
|
actual = np.asarray(actual)
|
||||||
except: # noqa
|
except BaseException:
|
||||||
raise TypeError("cannot compare '{}' to numpy.ndarray".format(actual))
|
raise TypeError("cannot compare '{}' to numpy.ndarray".format(actual))
|
||||||
|
|
||||||
if not np.isscalar(actual) and actual.shape != self.expected.shape:
|
if not np.isscalar(actual) and actual.shape != self.expected.shape:
|
||||||
|
|
|
@ -258,7 +258,7 @@ class CallInfo:
|
||||||
precise_start = perf_counter()
|
precise_start = perf_counter()
|
||||||
try:
|
try:
|
||||||
result = func()
|
result = func()
|
||||||
except: # noqa
|
except BaseException:
|
||||||
excinfo = ExceptionInfo.from_current()
|
excinfo = ExceptionInfo.from_current()
|
||||||
if reraise is not None and excinfo.errisinstance(reraise):
|
if reraise is not None and excinfo.errisinstance(reraise):
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -151,7 +151,7 @@ class TestCaseFunction(Function):
|
||||||
fail("".join(values), pytrace=False)
|
fail("".join(values), pytrace=False)
|
||||||
except (fail.Exception, KeyboardInterrupt):
|
except (fail.Exception, KeyboardInterrupt):
|
||||||
raise
|
raise
|
||||||
except: # noqa
|
except BaseException:
|
||||||
fail(
|
fail(
|
||||||
"ERROR: Unknown Incompatible Exception "
|
"ERROR: Unknown Incompatible Exception "
|
||||||
"representation:\n%r" % (rawexcinfo,),
|
"representation:\n%r" % (rawexcinfo,),
|
||||||
|
|
|
@ -239,7 +239,7 @@ class TestTraceback_f_g_h:
|
||||||
def f(n: int) -> None:
|
def f(n: int) -> None:
|
||||||
try:
|
try:
|
||||||
do_stuff()
|
do_stuff()
|
||||||
except: # noqa
|
except BaseException:
|
||||||
reraise_me()
|
reraise_me()
|
||||||
|
|
||||||
excinfo = pytest.raises(RuntimeError, f, 8)
|
excinfo = pytest.raises(RuntimeError, f, 8)
|
||||||
|
@ -445,7 +445,7 @@ class TestFormattedExcinfo:
|
||||||
exec(source.compile())
|
exec(source.compile())
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except: # noqa
|
except BaseException:
|
||||||
return _pytest._code.ExceptionInfo.from_current()
|
return _pytest._code.ExceptionInfo.from_current()
|
||||||
assert 0, "did not raise"
|
assert 0, "did not raise"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue