diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2013-06-10 08:37:12 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2013-06-10 08:37:12 (GMT) |
commit | 36451f076ba302c04bd511cd62f54fffc8e35d9b (patch) | |
tree | a174814d2b6f35ec288925393725ceb349ed6b6e | |
parent | 531381f207911db931470ed313be4f2df844d36b (diff) | |
parent | a822d366750ea0817276f35fd3adcd894472a70a (diff) | |
download | cpython-36451f076ba302c04bd511cd62f54fffc8e35d9b.zip cpython-36451f076ba302c04bd511cd62f54fffc8e35d9b.tar.gz cpython-36451f076ba302c04bd511cd62f54fffc8e35d9b.tar.bz2 |
(3.3->default) Ensure that the fix for #17269 also works on OSX 10.4
AI_NUMERICSERV isn't defined on OSX 10.4.
-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 a2de398..969677b 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1202,7 +1202,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 f1e310d..46265ad 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4975,7 +4975,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". |