From: Bob Halley Date: Wed, 19 Aug 2020 02:45:33 +0000 (-0700) Subject: On win32, skip valid IPv6 addresses that socket.inet_pton() erroneously thinks are... X-Git-Tag: v2.1.0rc1~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04d65197c72930fbc2857e7384418d6f045f7aa0;p=thirdparty%2Fdnspython.git On win32, skip valid IPv6 addresses that socket.inet_pton() erroneously thinks are invalid. --- diff --git a/tests/test_address.py b/tests/test_address.py index 98150f2c..1ee7022c 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -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))