summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2013-06-10 08:35:36 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2013-06-10 08:35:36 (GMT)
commit0e6283e68a9d6035e68a91904f13733df512dbce (patch)
treee9754ce34a651da1ddae396635a22bac1837e71f
parent729ad5cf561ba644322952b79051269f07bb1ec0 (diff)
downloadcpython-0e6283e68a9d6035e68a91904f13733df512dbce.zip
cpython-0e6283e68a9d6035e68a91904f13733df512dbce.tar.gz
cpython-0e6283e68a9d6035e68a91904f13733df512dbce.tar.bz2
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.py3
-rw-r--r--Modules/socketmodule.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 3b112e6..6e72180 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 238c849..2735ecc 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".