Skip to content

Raise correct exception out of Spines.__getattr__ #21570

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

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Nov 9, 2021

PR Summary

If the name does not exist, then __getattr__ should raise AttributeError, not ValueError.

Fixes #21554

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [n/a] New features are documented, with examples if plot related.
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [n/a] Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

If the name does not exist, then `__getattr__` should raise
`AttributeError`, not `ValueError`.

Fixes matplotlib#21554
@QuLogic QuLogic added this to the v3.4.4 milestone Nov 9, 2021
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks good, but I'm not sure this closes the issue though. Now, we'll at least get the right error, but it still isn't a super helpful message for the user.

AttributeError: 'Spines' object does not contain a '__deepcopy__' spine

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Approve for changing the error type.

It's however not a fix to the reported issue. deepcopy(figure) should not fail on some random internal state. Either we forbid it explicitly or somebody has to make it work with a reasonable meaning.

@timhoffm timhoffm merged commit b9065f7 into matplotlib:main Nov 9, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Nov 9, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Nov 9, 2021
@QuLogic QuLogic deleted the spine-getattr branch November 9, 2021 20:58
QuLogic added a commit that referenced this pull request Nov 9, 2021
…570-on-v3.5.x

Backport PR #21570 on branch v3.5.x (Raise correct exception out of Spines.__getattr__)
QuLogic added a commit that referenced this pull request Nov 10, 2021
…570-on-v3.4.x

Backport PR #21570 on branch v3.4.x (Raise correct exception out of Spines.__getattr__)
@QuLogic QuLogic modified the milestones: v3.4.4, v3.5.0 Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ValueError upon deepcopy of a Figure object
3 participants