Skip to content

MAINT: Chaining exceptions in numpy/core/_internal.py - #16747

Merged
seberg merged 2 commits into
numpy:masterfrom
abhinav-thimma:maint/chain-exceptions
Jul 4, 2020
Merged

seberg merged 2 commits into
numpy:masterfrom
abhinav-thimma:maint/chain-exceptions

Conversation

@abhinav-thimma

Copy link
Copy Markdown
Contributor

Changes related to #15986

  • added chaining for ValueError, TypeError, AttributeError
  • updated % formatted strings to f strings

- updated %formatted string to f strings
Comment thread numpy/core/_internal.py Outdated
raise ValueError(f"duplicate field name: {name}") from e
else:
raise ValueError("unknown field name: %s" % (name,))
raise ValueError(f"unknown field name: {name}") from e

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two should be from None

Comment thread numpy/core/_internal.py Outdated
except (TypeError, AttributeError) as e:
raise ValueError(
f'format number {len(result)+1} of "{astr}" is not recognized'
) from e

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should be from None, the error here isn't interesting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eric-wieser I will make the necessary corrections.

@seberg

seberg commented Jul 4, 2020

Copy link
Copy Markdown
Member

LGTM, thanks @abhinav-thimma and Eric.

@seberg
seberg merged commit 4771e3f into numpy:master Jul 4, 2020
@abhinav-thimma
abhinav-thimma deleted the maint/chain-exceptions branch July 4, 2020 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants