summaryrefslogtreecommitdiff
path: root/dns/_immutable_attr.py
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-08-13 17:30:04 -0700
committerBob Halley <halley@dnspython.org>2020-08-13 17:30:04 -0700
commit5b29466c962053c066b97451b5d51209fd0e4019 (patch)
tree2bfcb09a7c5921c77e55c3c5819a9425460dc727 /dns/_immutable_attr.py
parent2d5f54de0454e6f24f37d3f05944f4da4dc474b2 (diff)
downloaddnspython-5b29466c962053c066b97451b5d51209fd0e4019.tar.gz
apply the immutable init wrapper to __setstate__ too, if present
Diffstat (limited to 'dns/_immutable_attr.py')
-rw-r--r--dns/_immutable_attr.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/dns/_immutable_attr.py b/dns/_immutable_attr.py
index 9d76cdf..61aa1b1 100644
--- a/dns/_immutable_attr.py
+++ b/dns/_immutable_attr.py
@@ -60,9 +60,16 @@ def immutable(cls):
else:
# Mixin the Immutable class and follow the __init__ protocol.
class ncls(_Immutable, cls):
+
@_immutable_init
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+
+ if hasattr(cls, '__setstate__'):
+ @_immutable_init
+ def __setstate__(self, *args, **kwargs):
+ super().__setstate__(*args, **kwargs)
+
# make ncls have the same name and module as cls
ncls.__name__ = cls.__name__
ncls.__qualname__ = cls.__qualname__