]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
On win32, skip valid IPv6 addresses that socket.inet_pton() erroneously thinks are...
authorBob Halley <halley@dnspython.org>
Wed, 19 Aug 2020 02:45:33 +0000 (19:45 -0700)
committerBob Halley <halley@dnspython.org>
Wed, 19 Aug 2020 02:45:33 +0000 (19:45 -0700)
tests/test_address.py

index 98150f2ce1b1494d259c450c93444c65ea64ac08..1ee7022c4135bf7ad96b4b4ec3d230e67f59de0f 100644 (file)
@@ -248,13 +248,20 @@ class IPv6Tests(unittest.TestCase):
             "::0:a:b:c:d:e:f",
             "a:b:c:d:e:f:0::",
         )
-        if sys.platform == 'win32':
-            for s in valid:
-                try:
-                    socket.inet_pton(socket.AF_INET6, s)
-                except Exception:
-                    print('win32 rejects:', s)
+
+        win32_invalid = {
+            "::2:3:4:5:6:7:8",
+            "::2222:3333:4444:5555:6666:7777:8888",
+            "::2222:3333:4444:5555:6666:123.123.123.123",
+            "::0:0:0:0:0:0:0",
+            "::0:a:b:c:d:e:f",
+        }
+
         for s in valid:
+            if sys.platform == 'win32' and s in win32_invalid:
+                # socket.inet_pton() on win32 rejects some valid (as
+                # far as we can tell) IPv6 addresses.  Skip them.
+                continue
             self.assertEqual(dns.ipv6.inet_aton(s),
                              socket.inet_pton(socket.AF_INET6, s))