]> granicus.if.org Git - python/commitdiff
Ensure that the fix for #17269 also works on OSX 10.4
authorRonald Oussoren <ronaldoussoren@mac.com>
Mon, 10 Jun 2013 08:36:28 +0000 (10:36 +0200)
committerRonald Oussoren <ronaldoussoren@mac.com>
Mon, 10 Jun 2013 08:36:28 +0000 (10:36 +0200)
AI_NUMERICSERV isn't defined on OSX 10.4.

Lib/test/test_socket.py
Modules/socketmodule.c

index 546a10d23a7f733cde417539bcc10ab8626a9b2c..25bf0a189fa4852ed3a559168d4fbc9f2363f1f7 100644 (file)
@@ -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
index b9579283f81bed9c4acf8b39b1df3b0c647ce5a9..9b58a11bd5499c17a7a69b15166f7357df3dcaa3 100644 (file)
@@ -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".