Fixed frozen and cache_hash incompatibility#612
Merged
hynek merged 3 commits intopython-attrs:masterfrom Jan 13, 2020
Merged
Conversation
hynek
requested changes
Jan 8, 2020
809e0d0 to
a2a6713
Compare
pganssle
commented
Jan 8, 2020
Member
Author
pganssle
left a comment
There was a problem hiding this comment.
Thanks for the quick review Hynek!
This is a failing test for GH issue python-attrs#611, with the xfail decorator to be removed when the issue is fixed.
a2a6713 to
b7a5dcd
Compare
Fixes GH issue python-attrs#611: serialization of a class with frozen=True and cache_hash=True will now succeed rather than raising a FrozenInstanceError.
b7a5dcd to
fa5b63c
Compare
Member
Author
|
Oops, thanks to the coverage result I realized that the test was copying the class, not an instance of the class. This is what I get for skipping my usual semi-TDD style of putting the test under an Feel free to squash the commits if you don't like that style - I mainly do it to give an easy(-enough)-to-verify way to show that the test is probably testing what we expect. |
hynek
approved these changes
Jan 13, 2020
Member
|
Thanks, Paul! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This uses the same mechanism to clear the cache hash as
__hash__uses to set the cache hash in frozen classes - bypassing the object's__setattr__in favor ofobject.__setattr__. Neat trick.Fixes #611.
Pull Request Check List
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!
If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.
.pyi).changelog.d.If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!