[Python-checkins] cpython (merge 3.3 -> default): (3.3->default) Ensure that the fix for #17269 also works on OSX 10.4

ronald.oussoren python-checkins at python.org
Mon Jun 10 10:37:31 CEST 2013


http://hg.python.org/cpython/rev/062f1985a5b7
changeset:   84076:062f1985a5b7
parent:      84073:4a0017722910
parent:      84075:ef103e7e7af2
user:        Ronald Oussoren <ronaldoussoren at mac.com>
date:        Mon Jun 10 10:37:12 2013 +0200
summary:
  (3.3->default) Ensure that the fix for #17269 also works on OSX 10.4

AI_NUMERICSERV isn't defined on OSX 10.4.

files:
  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
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1202,7 +1202,8 @@
         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
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4975,7 +4975,7 @@
         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".

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list