summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-08-13 17:42:47 -0700
committerBob Halley <halley@dnspython.org>2020-08-13 17:42:47 -0700
commitb5f5facc465c2fde5361b27dad0dbf88c26a0603 (patch)
treeb1a5bb5988c9e2e094ffa093eecdf0f113f9bedc
parent5b29466c962053c066b97451b5d51209fd0e4019 (diff)
downloaddnspython-b5f5facc465c2fde5361b27dad0dbf88c26a0603.tar.gz
keep following init protocol for __setstate__ when ancestor is Immutable too
-rw-r--r--dns/_immutable_attr.py2
-rw-r--r--dns/_immutable_ctx.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/dns/_immutable_attr.py b/dns/_immutable_attr.py
index 61aa1b1..bf8aebc 100644
--- a/dns/_immutable_attr.py
+++ b/dns/_immutable_attr.py
@@ -56,6 +56,8 @@ def immutable(cls):
# Some ancestor already has the mixin, so just make sure we keep
# following the __init__ protocol.
cls.__init__ = _immutable_init(cls.__init__)
+ if hasattr(cls, '__setstate__'):
+ cls.__setstate__ = _immutable_init(cls.__setstate__)
ncls = cls
else:
# Mixin the Immutable class and follow the __init__ protocol.
diff --git a/dns/_immutable_ctx.py b/dns/_immutable_ctx.py
index d576689..400ab6c 100644
--- a/dns/_immutable_ctx.py
+++ b/dns/_immutable_ctx.py
@@ -47,6 +47,8 @@ def immutable(cls):
# Some ancestor already has the mixin, so just make sure we keep
# following the __init__ protocol.
cls.__init__ = _immutable_init(cls.__init__)
+ if hasattr(cls, '__setstate__'):
+ cls.__setstate__ = _immutable_init(cls.__setstate__)
ncls = cls
else:
# Mixin the Immutable class and follow the __init__ protocol.