-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAINT: Added Chain exceptions where appropriate #18400
MAINT: Added Chain exceptions where appropriate #18400
Conversation
numpy/lib/format.py
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should probably be from e
numpy/lib/format.py
Outdated
@@ -616,7 +616,7 @@ def _read_array_header(fp, version): | |||
dtype = descr_to_dtype(d['descr']) | |||
except TypeError: | |||
msg = "descr is not a valid dtype descriptor: {!r}" | |||
raise ValueError(msg.format(d['descr'])) | |||
raise ValueError(msg.format(d['descr'])) from None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from e
would be better here too
numpy/ma/mrecords.py
Outdated
@@ -657,7 +657,7 @@ def openfile(fname): | |||
try: | |||
f = open(fname) | |||
except IOError: | |||
raise IOError(f"No such file: '{fname}'") | |||
raise IOError(f"No such file: '{fname}'") from None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from e
again; otherwise if the open fails for permission reasons, all we'll see is "no such file"
c09c46f
to
0ca74f5
Compare
Hi @eric-wieser , I've update the PR. |
numpy/lib/format.py
Outdated
msg = "Cannot parse header: {!r}\nException: {!r}" | ||
raise ValueError(msg.format(header, e)) | ||
raise ValueError(msg.format(header, e)) from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one should remove the Exception: {!r}
bit, as otherwise the exception appears twice. The one that appears to to from e
appears in more detail, so we should remove the other one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll remove it and update the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated PR for this :)
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@eric-wieser Ping. |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Thanks @abhayaman669 . |
This PR is related to #15986
Thank you.