summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-06-04 12:19:39 (GMT)
committerHynek Schlawack <hs@ox.cx>2012-06-04 12:19:39 (GMT)
commitbcd304480f16f3f936a7bdbff4dfab41f8e30292 (patch)
tree3cd394791b9352fc3fca8a4f106fa1f375f1ce9c
parent7d74effc67281b505756e040437241e5b1436a7c (diff)
downloadcpython-bcd304480f16f3f936a7bdbff4dfab41f8e30292.zip
cpython-bcd304480f16f3f936a7bdbff4dfab41f8e30292.tar.gz
cpython-bcd304480f16f3f936a7bdbff4dfab41f8e30292.tar.bz2
#14814: Use correct comparison for IP addresses
ipaddress._BaseV4.is_unspecified() compared IP addresses using "in" which fails.
-rw-r--r--Lib/ipaddress.py2
-rw-r--r--Lib/test/test_ipaddress.py1
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index a8edcd1..25bcccd 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -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)
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index aff4ff9..5b7d013 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -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)