From: Serhiy Storchaka Date: Mon, 26 Jan 2015 08:11:39 +0000 (+0200) Subject: Issue #23268: Fixed bugs in the comparison of ipaddress classes. X-Git-Tag: v3.5.0a1~109 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ffd48c9e3d0b9bd6fffd4a5ada6a112fea767e2e;p=python Issue #23268: Fixed bugs in the comparison of ipaddress classes. --- ffd48c9e3d0b9bd6fffd4a5ada6a112fea767e2e diff --cc Lib/ipaddress.py index 2ba98d8926,ac03c36ce0..6c225f3037 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@@ -557,16 -514,14 +524,17 @@@ class _IPAddressBase pass # Invert the bits, and try matching a /0+1+/ hostmask instead. - ip_int ^= self._ALL_ONES + ip_int ^= cls._ALL_ONES try: - return self._prefix_from_ip_int(ip_int) + return cls._prefix_from_ip_int(ip_int) except ValueError: - self._report_invalid_netmask(ip_str) + cls._report_invalid_netmask(ip_str) + + def __reduce__(self): + return self.__class__, (str(self),) + @functools.total_ordering class _BaseAddress(_IPAddressBase): """A generic IP object. @@@ -620,10 -579,8 +587,11 @@@ def _get_address_key(self): return (self._version, self) + def __reduce__(self): + return self.__class__, (self._ip,) + + @functools.total_ordering class _BaseNetwork(_IPAddressBase): """A generic IP network object. diff --cc Lib/test/test_ipaddress.py index 5ec2cd45fe,bfb569950f..e985329117 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@@ -7,8 -7,8 +7,9 @@@ import unittest import re import contextlib + import functools import operator +import pickle import ipaddress