diff options
| author | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-07 23:05:59 +1000 |
|---|---|---|
| committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-07 23:05:59 +1000 |
| commit | 2eb9a5a765cacdcec82756c744d09e631f565f7d (patch) | |
| tree | 1f55f1fd0974ec61c64b7c2bafa1a817c4a0cf51 /Lib/ipaddress.py | |
| parent | 58790c3c58f54751002895ec5da346067f25ee5b (diff) | |
| download | cpython-2eb9a5a765cacdcec82756c744d09e631f565f7d.tar.gz | |
Issue 14814: Correctly return NotImplemented from ipaddress._BaseNetwork.__eq__
Diffstat (limited to 'Lib/ipaddress.py')
| -rw-r--r-- | Lib/ipaddress.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index e788c0a5b7..b1e07fc992 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) |
