From: Bob Halley Date: Fri, 14 Aug 2020 00:42:47 +0000 (-0700) Subject: keep following init protocol for __setstate__ when ancestor is Immutable too X-Git-Tag: v2.1.0rc1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5f5facc465c2fde5361b27dad0dbf88c26a0603;p=thirdparty%2Fdnspython.git keep following init protocol for __setstate__ when ancestor is Immutable too --- diff --git a/dns/_immutable_attr.py b/dns/_immutable_attr.py index 61aa1b17..bf8aebc5 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 d5766899..400ab6ce 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.