diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-10-22 19:12:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-22 19:12:58 (GMT) |
commit | 3c3c489d41f3bca783d48bd6bbc70333093d9a99 (patch) | |
tree | b6f06d3709d149a5e189aacafbd4ae164bb35193 /Lib | |
parent | aaa755dd48ac35a392bad211b21bef8808f81719 (diff) | |
download | cpython-3c3c489d41f3bca783d48bd6bbc70333093d9a99.zip cpython-3c3c489d41f3bca783d48bd6bbc70333093d9a99.tar.gz cpython-3c3c489d41f3bca783d48bd6bbc70333093d9a99.tar.bz2 |
[3.11] gh-110196: Fix ipaddress.IPv6Address.__reduce__ (GH-110198) (GH-111190)
(cherry picked from commit 767f416feb551f495bacfff1e9ba1e6672c2f24e)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ipaddress.py | 3 | ||||
-rw-r--r-- | Lib/test/test_ipaddress.py | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 1cb71d8..16ba16c 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1941,6 +1941,9 @@ class IPv6Address(_BaseV6, _BaseAddress): return False return self._scope_id == getattr(other, '_scope_id', None) + def __reduce__(self): + return (self.__class__, (str(self),)) + @property def scope_id(self): """Identifier of a particular zone of the address's scope. diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index a5388b2..fc27628 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -4,6 +4,7 @@ """Unittest for ipaddress module.""" +import copy import unittest import re import contextlib @@ -542,11 +543,17 @@ class AddressTestCase_v6(BaseTestCase, CommonTestMixin_v6): def test_pickle(self): self.pickle_test('2001:db8::') + self.pickle_test('2001:db8::%scope') def test_weakref(self): weakref.ref(self.factory('2001:db8::')) weakref.ref(self.factory('2001:db8::%scope')) + def test_copy(self): + addr = self.factory('2001:db8::%scope') + self.assertEqual(addr, copy.copy(addr)) + self.assertEqual(addr, copy.deepcopy(addr)) + class NetmaskTestMixin_v4(CommonTestMixin_v4): """Input validation on interfaces and networks is very similar""" |