mirror of
https://github.com/python/cpython.git
synced 2025-10-06 07:02:33 +00:00
[3.6] bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (GH-879) (#2217)
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.
(cherry picked from commit 7bd8d3e794
)
This commit is contained in:
parent
f75f6edb1f
commit
cf58dfb44c
3 changed files with 36 additions and 10 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue