Commit bcd30448 authored by Hynek Schlawack's avatar Hynek Schlawack

#14814: Use correct comparison for IP addresses

ipaddress._BaseV4.is_unspecified() compared IP addresses using "in" which
fails.
parent 7d74effc
......@@ -1130,7 +1130,7 @@ class _BaseV4:
"""
unspecified_address = IPv4Address('0.0.0.0')
if isinstance(self, _BaseAddress):
return self in unspecified_address
return self == unspecified_address
return (self.network_address == self.broadcast_address ==
unspecified_address)
......
......@@ -837,6 +837,7 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertEqual(False, ipaddress.ip_network('128.0.0.0').is_loopback)
# test addresses
self.assertEqual(True, ipaddress.ip_address('0.0.0.0').is_unspecified)
self.assertEqual(True, ipaddress.ip_address('224.1.1.1').is_multicast)
self.assertEqual(False, ipaddress.ip_address('240.0.0.0').is_multicast)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment