summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-08-23 23:32:47 +0000
committerpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-08-23 23:32:47 +0000
commit0f305393c4a23ef9daa31d0aa25c09e473ef7088 (patch)
tree3beda8f2638d923270985ab82b8f86d9ca925ef7
parent61a53e10d8e3c22aa5ffd609a7a677e5b84bad89 (diff)
downloadipaddr-py-0f305393c4a23ef9daa31d0aa25c09e473ef7088.tar.gz
+ containment test should always return false on mixed-type tests.
git-svn-id: https://ipaddr-py.googlecode.com/svn@186 09200d28-7f98-11dd-ad27-0f66e57d2035
-rw-r--r--trunk/ipaddr.py3
-rwxr-xr-xtrunk/ipaddr_test.py3
2 files changed, 6 insertions, 0 deletions
diff --git a/trunk/ipaddr.py b/trunk/ipaddr.py
index daed035..4fe6e11 100644
--- a/trunk/ipaddr.py
+++ b/trunk/ipaddr.py
@@ -594,6 +594,9 @@ class _BaseNet(_IPAddrBase):
return hash(int(self.network) ^ int(self.netmask))
def __contains__(self, other):
+ # always false if one is v4 and the other is v6.
+ if self._version != other._version:
+ return False
# dealing with another network.
if isinstance(other, _BaseNet):
return (self.network <= other.network and
diff --git a/trunk/ipaddr_test.py b/trunk/ipaddr_test.py
index 7d7ed0e..b3f0409 100755
--- a/trunk/ipaddr_test.py
+++ b/trunk/ipaddr_test.py
@@ -147,6 +147,9 @@ class IpaddrUnitTest(unittest.TestCase):
v6addr = ipaddr.IPAddress('::1')
v6net = ipaddr.IPNetwork('::1/128')
+ self.assertFalse(v4net.__contains__(v6net))
+ self.assertFalse(v6net.__contains__(v4net))
+
self.assertRaises(TypeError, lambda: v4addr < v4net)
self.assertRaises(TypeError, lambda: v4addr > v4net)
self.assertRaises(TypeError, lambda: v4net < v4addr)