mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue 14814: Correctly return NotImplemented from ipaddress._BaseNetwork.__eq__
This commit is contained in:
parent
d46f7d209b
commit
9a9c28ce7a
3 changed files with 25 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue