summaryrefslogtreecommitdiffstats
path: root/Lib/ipaddr.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2009-06-02 05:25:34 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2009-06-02 05:25:34 (GMT)
commit61e7fbf2c151373e33e3d3e3eb8dc4164cf28f9f (patch)
tree74c2e8c9ebea2d6e3665bcc9b72419969963e64c /Lib/ipaddr.py
parent25de0dd89b902da57a3fe5bcdccbf21a3f8db27a (diff)
downloadcpython-61e7fbf2c151373e33e3d3e3eb8dc4164cf28f9f.zip
cpython-61e7fbf2c151373e33e3d3e3eb8dc4164cf28f9f.tar.gz
cpython-61e7fbf2c151373e33e3d3e3eb8dc4164cf28f9f.tar.bz2
Fixes issue6169: it was possible for two ipaddr network addresses to compare
as both < and > than eachother.
Diffstat (limited to 'Lib/ipaddr.py')
-rw-r--r--Lib/ipaddr.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/Lib/ipaddr.py b/Lib/ipaddr.py
index b04a4b8..a2d9e93 100644
--- a/Lib/ipaddr.py
+++ b/Lib/ipaddr.py
@@ -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