summaryrefslogtreecommitdiffstats
path: root/Lib/ipaddress.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-07-07 13:05:59 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-07-07 13:05:59 (GMT)
commit9a9c28ce7a051b37a91e4fc7aef70bcdcda25047 (patch)
tree23e80dcda26b4e1448de538eabf2800d9752851f /Lib/ipaddress.py
parentd46f7d209b0d6db48f63c8317df9bfefbed73ae7 (diff)
downloadcpython-9a9c28ce7a051b37a91e4fc7aef70bcdcda25047.zip
cpython-9a9c28ce7a051b37a91e4fc7aef70bcdcda25047.tar.gz
cpython-9a9c28ce7a051b37a91e4fc7aef70bcdcda25047.tar.bz2
Issue 14814: Correctly return NotImplemented from ipaddress._BaseNetwork.__eq__
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r--Lib/ipaddress.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index e788c0a5..b1e07fc 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -651,12 +651,12 @@ class _BaseNetwork(_IPAddressBase):
return not lt
def __eq__(self, other):
- if not isinstance(other, _BaseNetwork):
- raise TypeError('%s and %s are not of the same type' % (
- self, other))
- return (self._version == other._version and
- self.network_address == other.network_address and
- int(self.netmask) == int(other.netmask))
+ try:
+ return (self._version == other._version and
+ self.network_address == other.network_address and
+ int(self.netmask) == int(other.netmask))
+ except AttributeError:
+ return NotImplemented
def __ne__(self, other):
eq = self.__eq__(other)