diff options
| author | Bob Halley <halley@dnspython.org> | 2020-08-13 17:30:04 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-08-13 17:30:04 -0700 |
| commit | 5b29466c962053c066b97451b5d51209fd0e4019 (patch) | |
| tree | 2bfcb09a7c5921c77e55c3c5819a9425460dc727 /dns/_immutable_attr.py | |
| parent | 2d5f54de0454e6f24f37d3f05944f4da4dc474b2 (diff) | |
| download | dnspython-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.py | 7 |
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__ |
