]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
keep following init protocol for __setstate__ when ancestor is Immutable too
authorBob Halley <halley@dnspython.org>
Fri, 14 Aug 2020 00:42:47 +0000 (17:42 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 14 Aug 2020 00:42:47 +0000 (17:42 -0700)
dns/_immutable_attr.py
dns/_immutable_ctx.py

index 61aa1b173a09cb0b94a9437895ec120861b77188..bf8aebc560148a803f38088a19736c7bd683564d 100644 (file)
@@ -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.
index d57668999655d6246ed4b44aa917016febf30ee1..400ab6ce167e9bddea88b350ebee26c6d7805af7 100644 (file)
@@ -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.