diff options
-rw-r--r-- | Lib/test/test_socket.py | 3 | ||||
-rw-r--r-- | 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 546a10d..25bf0a1 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1167,7 +1167,8 @@ class GeneralModuleTests(unittest.TestCase): self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800') # 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 test_getnameinfo(self): # only IP addresses are allowed diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index b957928..9b58a11 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5041,7 +5041,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) PyErr_SetString(PyExc_OSError, "Int or String expected"); 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". |