8000 Update ipaddress from CPython v3.12.3 (#5312) · RustPython/RustPython@72033ab · GitHub
[go: up one dir, main page]

Skip to content

Commit 72033ab

Browse files
authored
Update ipaddress from CPython v3.12.3 (#5312)
Co-authored-by: CPython Developers <>
1 parent 3f63501 commit 72033ab

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Lib/ipaddress.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,6 @@ def _string_from_ip_int(cls, ip_int=None):
18211821
def _explode_shorthand_ip_string(self):
18221822
"""Expand a shortened IPv6 address.
18231823
1824-
Args:
1825-
ip_str: A string, the IPv6 address.
1826-
18271824
Returns:
18281825
A string, the expanded IPv6 address.
18291826
@@ -1941,6 +1938,9 @@ def __eq__(self, other):
19411938
return False
19421939
return self._scope_id == getattr(other, '_scope_id', None)
19431940

1941+
def __reduce__(self):
1942+
return (self.__class__, (str(self),))
1943+
19441944
@property
19451945
def scope_id(self):
19461946
"""Identifier of a particular zone of the address's scope.

Lib/test/test_ipaddress.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""Unittest for ipaddress module."""
55

66

7+
import copy
78
import unittest
89
import re
910
import contextlib
@@ -542,11 +543,17 @@ def assertBadPart(addr, part):
542543

543544
def test_pickle(self):
544545
self.pickle_test('2001:db8::')
546+
self.pickle_test('2001:db8::%scope')
545547

546548
def test_weakref(self):
547549
weakref.ref(self.factory('2001:db8::'))
548550
weakref.ref(self.factory('2001:db8::%scope'))
549551

552+
def test_copy(self):
553+
addr = self.factory('2001:db8::%scope')
554+
self.assertEqual(addr, copy.copy(addr))
555+
self.assertEqual(addr, copy.deepcopy(addr))
556+
550557

551558
class NetmaskTestMixin_v4(CommonTestMixin_v4):
552559
"""Input validation on interfaces and networks is very similar"""

0 commit comments

Comments
 (0)
0