diff options
author | Abhay Raghuvanshi <abhayaman669@gmail.com> | 2021-03-19 01:49:20 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 14:19:20 -0600 |
commit | 9c68c2f7b1b2128a3b4af2134565f60d286fa8b9 (patch) | |
tree | 6ce82ac0a4e3074f89b0d2b883d2e02345f90b3d /numpy/lib/format.py | |
parent | bb7a31a6a852ecc64d3f7cffb70121fc8bef20eb (diff) | |
download | numpy-9c68c2f7b1b2128a3b4af2134565f60d286fa8b9.tar.gz |
MAINT: Added Chain exceptions where appropriate (#18394)
* Added chain exception in _bits_of func
* Added chain exception
* Added chain exception in unixccompiler.py
* Added chain exception in config.py
* Added chain exception in fcompiler __init__.py
* Added chain exception in compaq.py
* Added chain exception in format.py
* Updated raise chain exception
* STY: Break long line.
Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
Diffstat (limited to 'numpy/lib/format.py')
-rw-r--r-- | numpy/lib/format.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 5d951e262..ac5f75fba 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -378,7 +378,7 @@ def _wrap_header(header, version): header_prefix = magic(*version) + struct.pack(fmt, hlen + padlen) except struct.error: msg = "Header length {} too big for version={}".format(hlen, version) - raise ValueError(msg) + raise ValueError(msg) from None # Pad the header with spaces and a final newline such that the magic # string, the header-length short and the header are aligned on a @@ -595,7 +595,7 @@ def _read_array_header(fp, version): d = safe_eval(header) except SyntaxError as e: msg = "Cannot parse header: {!r}\nException: {!r}" - raise ValueError(msg.format(header, e)) + raise ValueError(msg.format(header, e)) from None if not isinstance(d, dict): msg = "Header is not a dictionary: {!r}" raise ValueError(msg.format(d)) @@ -614,9 +614,9 @@ def _read_array_header(fp, version): raise ValueError(msg.format(d['fortran_order'])) try: dtype = descr_to_dtype(d['descr']) - except TypeError: + except TypeError as e: msg = "descr is not a valid dtype descriptor: {!r}" - raise ValueError(msg.format(d['descr'])) + raise ValueError(msg.format(d['descr'])) from e return d['shape'], d['fortran_order'], dtype |