diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-06-03 13:41:26 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-06-03 13:59:51 +0100 |
commit | 1608e53072b035bd40de7a202e75354f0e802120 (patch) | |
tree | a530210ff9fa4f44e1e3061af05df3f55ec96c35 /numpy/ma | |
parent | 0e4610e30aabaf32c037fc94c869a20f2435a8f1 (diff) | |
download | numpy-1608e53072b035bd40de7a202e75354f0e802120.tar.gz |
BUG: KeyboardInterrupt is swallowed all over the place
Bare except is very rarely the right thing
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/core.py | 4 | ||||
-rw-r--r-- | numpy/ma/extras.py | 2 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 4 | ||||
-rw-r--r-- | numpy/ma/tests/test_extras.py | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index d9401fa1d..b253b6f16 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -1068,7 +1068,7 @@ class _MaskedBinaryOperation: # any errors, just abort; impossible to guarantee masked values try: np.copyto(result, da, casting='unsafe', where=m) - except: + except Exception: pass # Transforms to a (subclass of) MaskedArray @@ -1214,7 +1214,7 @@ class _DomainedBinaryOperation: # only add back if it can be cast safely if np.can_cast(masked_da.dtype, result.dtype, casting='safe'): result += masked_da - except: + except Exception: pass # Transforms to a (subclass of) MaskedArray diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index d8ea3de8c..0a68dfc7d 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -778,7 +778,7 @@ def _median(a, axis=None, out=None, overwrite_input=False): # not necessary for scalar True/False masks try: np.copyto(low.mask, high.mask, where=odd) - except: + except Exception: pass if np.issubdtype(asorted.dtype, np.inexact): diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index ef5f5fd53..77aae2b94 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -276,7 +276,7 @@ class MaskedRecords(MaskedArray, object): try: # Is attr a generic attribute ? ret = object.__setattr__(self, attr, val) - except: + except Exception: # Not a generic attribute: exit if it's not a valid field fielddict = ndarray.__getattribute__(self, 'dtype').fields or {} optinfo = ndarray.__getattribute__(self, '_optinfo') or {} @@ -294,7 +294,7 @@ class MaskedRecords(MaskedArray, object): # internal attribute. try: object.__delattr__(self, attr) - except: + except Exception: return ret # Let's try to set the field try: diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py index 4b7fe07b6..18198d4a4 100644 --- a/numpy/ma/tests/test_extras.py +++ b/numpy/ma/tests/test_extras.py @@ -737,7 +737,7 @@ class TestMedian(TestCase): for axis, over in args: try: np.ma.median(x, axis=axis, overwrite_input=over) - except: + except Exception: raise AssertionError(msg % (mask, ndmin, axis, over)) # Invalid axis values should raise exception |