summaryrefslogtreecommitdiffstats
path: root/Lib/ipaddress.py
diff options
context:
space:
mode:
authors-sanjay <sanjay537@gmail.com>2017-04-01 06:09:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-04-01 06:09:53 (GMT)
commit7bd8d3e794782582a4ad1c9749424fff86802c3e (patch)
tree8d61336154beda73513828f3451ad62e894ac7fc /Lib/ipaddress.py
parent1f5425ff69ea0531d869b4f9fa28bd3f66ca3de7 (diff)
downloadcpython-7bd8d3e794782582a4ad1c9749424fff86802c3e.zip
cpython-7bd8d3e794782582a4ad1c9749424fff86802c3e.tar.gz
cpython-7bd8d3e794782582a4ad1c9749424fff86802c3e.tar.bz2
bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (#879)
the original logic was just comparing the network address but this is wrong because if the network address is equal then we need to compare the ip address for breaking the tie add more ip_interface comparison tests
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r--Lib/ipaddress.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index 20f33cb..70746f8 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -1410,7 +1410,8 @@ class IPv4Interface(IPv4Address):
if address_less is NotImplemented:
return NotImplemented
try:
- return self.network < other.network
+ return (self.network < other.network or
+ self.network == other.network and address_less)
except AttributeError:
# We *do* allow addresses and interfaces to be sorted. The
# unassociated address is considered less than all interfaces.
@@ -2100,7 +2101,8 @@ class IPv6Interface(IPv6Address):
if address_less is NotImplemented:
return NotImplemented
try:
- return self.network < other.network
+ return (self.network < other.network or
+ self.network == other.network and address_less)
except AttributeError:
# We *do* allow addresses and interfaces to be sorted. The
# unassociated address is considered less than all interfaces.