From 0e6283e68a9d6035e68a91904f13733df512dbce Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Mon, 10 Jun 2013 10:35:36 +0200 Subject: [PATCH] Ensure that the fix for #17269 also works on OSX 10.4 AI_NUMERICSERV isn't defined on OSX 10.4. --- Lib/test/test_socket.py | 3 ++- Modules/socketmodule.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 3b112e68384a..6e7218034d9c 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -666,7 +666,8 @@ class GeneralModuleTests(unittest.TestCase): socket.AI_PASSIVE) # Issue 17269 - socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV) + if hasattr(socket, 'AI_NUMERICSERV'): + socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV) def check_sendall_interrupted(self, with_timeout): # socketpair() is not stricly required, but it makes things easier. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 238c849b8459..2735ecc77359 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4179,7 +4179,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args) "getaddrinfo() argument 2 must be integer or string"); goto err; } -#ifdef __APPLE__ +#if defined(__APPLE__) && defined(AI_NUMERICSERV) if ((flags & AI_NUMERICSERV) && (pptr == NULL || (pptr[0] == '0' && pptr[1] == 0))) { /* On OSX upto at least OSX 10.8 getaddrinfo crashes * if AI_NUMERICSERV is set and the servname is NULL or "0". -- 2.47.3