# Issue #6697.
self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
- # Issue 17269: test workaround for OS X platform bug segfault
if hasattr(socket, 'AI_NUMERICSERV'):
+ self.assertRaises(socket.gaierror, socket.getaddrinfo, "localhost", "http",
+ flags=socket.AI_NUMERICSERV)
+
+ # Issue 17269: test workaround for OS X platform bug segfault
try:
# The arguments here are undefined and the call may succeed
# or fail. All we care here is that it doesn't segfault.
#undef AI_PASSIVE
#undef AI_CANONNAME
#undef AI_NUMERICHOST
+#undef AI_NUMERICSERV
#undef AI_MASK
#undef AI_ALL
#undef AI_V4MAPPED_CFG
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
+#define AI_NUMERICSERV 0x00000008 /* prevent service resolution */
/* valid flags for addrinfo */
-#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
+#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */