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.
Prior to #489, this used to work:
The issue is that
frozenis implemented by throwing an error in__setattr__, and clearing the hash cache callssetattr. I think this can be solved by using the same mechanism that_make_hashuses 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.