Skip to content

frozen=True incompatible with cache_hash=True as of 19.1.0 #611

@pganssle

Description

@pganssle

Prior to #489, this used to work:

import attr
import copy

@attr.s(frozen=True, cache_hash=True)
class FrozenWithCache:
    pass


if __name__ == "__main__":
    copy.deepcopy(FrozenWithCache())

The issue is that frozen is implemented by throwing an error in __setattr__, and clearing the hash cache calls setattr. I think this can be solved by using the same mechanism that _make_hash uses for frozen classes, but I have not tried implementing this before.

Another option is to not clear the hash cache on serialization for frozen classes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions