Skip to content

MNT: make _setattr_cm more forgiving #17649

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 2 commits into from
Jun 16, 2020

Conversation

tacaswell
Copy link
Member

@tacaswell tacaswell commented Jun 16, 2020

PR Summary

Our attempts to identify the set of cases we wanted to support did not
correctly capture all relevant cases. This tries to simplify the
logic:

  • if the attribute is in the instance dict, stash and restore it via
    setattr at the end
  • if the attribute is not on the object, delete it with delattr at
    the end
  • if the object has the attribute, but it is not in the instance
    dict:
    • if it is a property, stash and restore the old value
    • in all other cases assume that setattr will put the value in the
      instance dict and delattr will do what we want on the way out

closes #17646

Alternative to #17648

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant

Our attempts to identify the set of cases we wanted to support did not
correctly capture all relevant cases.  This tries to simplify the
logic:

 - if the attribute is in the instance dict, stash and restore it via
   setattr at the end
 - if the attribute is not on the object, delete it with delattr at
   the end
 - if the object has the attribute, but it is not in the instance
   dict:
   - if it is a property, stash and restore the old value
   - in all other cases assume that setattr will put the value in the
     instance dict and delattr will do what we want on the way out

closes matplotlib#17646
@tacaswell tacaswell modified the milestones: v3.2.2, v3.3.0 Jun 16, 2020
Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

works for me :)
delattr seems like the right way to go indeed.

@anntzer anntzer mentioned this pull request Jun 16, 2020
6 tasks
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@tacaswell
Copy link
Member Author

I'm self-merging on reviews from @anntzer and @QuLogic .

@tacaswell tacaswell merged commit d479a91 into matplotlib:master Jun 16, 2020
@tacaswell tacaswell deleted the fix_setattr_cm branch June 16, 2020 23:52
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.

more conservative setattr_cm broke mplcairo
3 participants