From b5f5facc465c2fde5361b27dad0dbf88c26a0603 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 13 Aug 2020 17:42:47 -0700 Subject: keep following init protocol for __setstate__ when ancestor is Immutable too --- dns/_immutable_attr.py | 2 ++ dns/_immutable_ctx.py | 2 ++ 2 files changed, 4 insertions(+) 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. -- cgit v1.2.1