mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fixes issue6169: it was possible for two ipaddr network addresses to compare
as both < and > than eachother.
This commit is contained in:
parent
25de0dd89b
commit
61e7fbf2c1
2 changed files with 30 additions and 19 deletions
|
@ -10,7 +10,7 @@ and prefixes.
|
|||
|
||||
"""
|
||||
|
||||
__version__ = '1.1.0'
|
||||
__version__ = '1.1.1'
|
||||
|
||||
import struct
|
||||
|
||||
|
@ -204,17 +204,25 @@ class BaseIP(object):
|
|||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
return (self.version < other.version
|
||||
or self.ip < other.ip
|
||||
or self.netmask < other.netmask)
|
||||
if self.version != other.version:
|
||||
return self.version < other.version
|
||||
if self.ip != other.ip:
|
||||
return self.ip < other.ip
|
||||
if self.netmask != other.netmask:
|
||||
return self.netmask < other.netmask
|
||||
return False
|
||||
except AttributeError:
|
||||
return NotImplemented
|
||||
|
||||
def __gt__(self, other):
|
||||
try:
|
||||
return (self.version > other.version
|
||||
or self.ip > other.ip
|
||||
or self.netmask > other.netmask)
|
||||
if self.version != other.version:
|
||||
return self.version > other.version
|
||||
if self.ip != other.ip:
|
||||
return self.ip > other.ip
|
||||
if self.netmask != other.netmask:
|
||||
return self.netmask > other.netmask
|
||||
return False
|
||||
except AttributeError:
|
||||
return NotImplemented
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue