-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
Fixed frozen and cache_hash incompatibility #612
Conversation
809e0d0
to
a2a6713
Compare
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.
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
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. |
Thanks, Paul! |
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!