diff options
author | Zuhair Ali-Khan <zaak7179@gmail.com> | 2020-06-04 00:28:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 08:28:58 +0300 |
commit | 489de42a9585615ca9962a83882896069357ab97 (patch) | |
tree | b9bbdd256032d1f0e95a70dac89c88f08d518d9d /numpy/core/records.py | |
parent | 9ec27a3f5b81e6a7e808836410c9b6a73204c27e (diff) | |
download | numpy-489de42a9585615ca9962a83882896069357ab97.tar.gz |
MAINT: Chain some exceptions. (#16418)
* ENH: Chain extensions in numpy and numpy/core
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Co-authored-by: Zuhair Ali-Khan <54608785+zalikh2@users.noreply.github.com>
Diffstat (limited to 'numpy/core/records.py')
-rw-r--r-- | numpy/core/records.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py index 7e1c0d591..464615450 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -461,8 +461,8 @@ class recarray(ndarray): fielddict = ndarray.__getattribute__(self, 'dtype').fields try: res = fielddict[attr][:2] - except (TypeError, KeyError): - raise AttributeError("recarray has no attribute %s" % attr) + except (TypeError, KeyError) as e: + raise AttributeError("recarray has no attribute %s" % attr) from e obj = self.getfield(*res) # At this point obj will always be a recarray, since (see @@ -509,8 +509,10 @@ class recarray(ndarray): return ret try: res = fielddict[attr][:2] - except (TypeError, KeyError): - raise AttributeError("record array has no attribute %s" % attr) + except (TypeError, KeyError) as e: + raise AttributeError( + "record array has no attribute %s" % attr + ) from e return self.setfield(val, *res) def __getitem__(self, indx): |