Issue #7171: Add Windows implementation of `inet_ntop and inet_pton` to socket module.

This commit is contained in:
Atsuo Ishimoto 2012-07-16 15:16:54 +09:00
parent 29828a6fa9
commit da0fc14d46
3 changed files with 124 additions and 4 deletions

View file

@ -980,6 +980,14 @@ class GeneralModuleTests(unittest.TestCase):
return
except ImportError:
return
if sys.platform == "win32":
try:
inet_pton(AF_INET6, '::')
except OSError as e:
if e.winerror == 10022:
return # IPv6 might not be installed on this PC
f = lambda a: inet_pton(AF_INET6, a)
assertInvalid = lambda a: self.assertRaises(
(OSError, ValueError), f, a
@ -1058,6 +1066,14 @@ class GeneralModuleTests(unittest.TestCase):
return
except ImportError:
return
if sys.platform == "win32":
try:
inet_ntop(AF_INET6, b'\x00' * 16)
except OSError as e:
if e.winerror == 10022:
return # IPv6 might not be installed on this PC
f = lambda a: inet_ntop(AF_INET6, a)
assertInvalid = lambda a: self.assertRaises(
(OSError, ValueError), f, a