diff options
author | Peter Moody <pmoody@google.com> | 2011-02-08 01:56:52 +0000 |
---|---|---|
committer | Peter Moody <pmoody@google.com> | 2011-02-08 01:56:52 +0000 |
commit | 6c49a8ad5687d11e9162648d546c90b309199fe6 (patch) | |
tree | 0d28a919f147e5edba9505b5843f4dde825d0a36 /ipaddr.py | |
parent | a03e20ccb1228b9791f224f2db714c38fc9728d0 (diff) | |
download | ipaddr-py-6c49a8ad5687d11e9162648d546c90b309199fe6.tar.gz |
+ fix broken network/address comparisons.
git-svn-id: https://ipaddr-py.googlecode.com/svn/trunk@206 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'ipaddr.py')
-rw-r--r-- | ipaddr.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -442,8 +442,7 @@ class _BaseIP(_IPAddrBase): def __eq__(self, other): try: return (self._ip == other._ip - and self._version == other._version - and isinstance(other, _BaseIP)) + and self._version == other._version) except AttributeError: return NotImplemented @@ -608,7 +607,11 @@ class _BaseNet(_IPAddrBase): and self.network == other.network and int(self.netmask) == int(other.netmask)) except AttributeError: - return NotImplemented + if isinstance(other, _BaseIP): + # If other is a _BaseIP, we pretend it's a network for + # this equality test. It's a slight hack, but it's a + # convenient one. + return self == IPNetwork(other._ip, version=other._version) def __ne__(self, other): eq = self.__eq__(other) |