From 645aaa728d515558725eb4d9bf8414612dfe4513 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 12 May 2020 12:07:56 +0300 Subject: python_api: reduce scope of a `except BaseException` in ApproxNumpy I'm not sure if it can even raise at all, but catching BaseException would swallow ctrl-C and such and is definitely inappropriate here. --- src/_pytest/python_api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/_pytest/python_api.py') diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index a523caae5..29c8af7e2 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -123,8 +123,10 @@ class ApproxNumpy(ApproxBase): if not np.isscalar(actual): try: actual = np.asarray(actual) - except BaseException: - raise TypeError("cannot compare '{}' to numpy.ndarray".format(actual)) + except Exception as e: + raise TypeError( + "cannot compare '{}' to numpy.ndarray".format(actual) + ) from e if not np.isscalar(actual) and actual.shape != self.expected.shape: return False -- cgit v1.2.3