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.
This commit is contained in:
Ran Benita 2020-05-12 12:07:56 +03:00
parent 23c9856857
commit 645aaa728d
1 changed files with 4 additions and 2 deletions

View File

@ -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