Merged revisions 73135 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73135 | gregory.p.smith | 2009-06-01 22:25:34 -0700 (Mon, 01 Jun 2009) | 3 lines

  Fixes issue6169: it was possible for two ipaddr network addresses to compare
  as both < and > than eachother.
........
This commit is contained in:
Gregory P. Smith 2009-06-02 05:29:37 +00:00
parent b7ffad5b28
commit 181bdc6374
2 changed files with 30 additions and 19 deletions

View file

@ -10,7 +10,7 @@ and prefixes.
"""
__version__ = '1.1.0'
__version__ = '1.1.1'
import struct
@ -206,17 +206,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