Skip to content

Commit

Permalink
Ensure that the fix for python#17269 also works on OSX 10.4
Browse files Browse the repository at this point in the history
AI_NUMERICSERV isn't defined on OSX 10.4.
  • Loading branch information
ronaldoussoren committed Jun 10, 2013
1 parent 6f50b81 commit a822d36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,8 @@ def testGetaddrinfo(self):
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
Expand Down
2 changes: 1 addition & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down

0 comments on commit a822d36

Please sign in to comment.