diff Modules/socketmodule.c @ 64113:ca2a859e9bf6

fix issue #8866: parameters passed to socket.getaddrinfo can now be specified as single keyword arguments.
author Giampaolo Rodolà <g.rodola@gmail.com>
date Tue, 17 Aug 2010 15:30:23 +0000
parents 60076f28c023
children b624c7417ad4
line wrap: on
line diff
--- a/Modules/socketmodule.c	Tue Aug 17 15:07:14 2010 +0000
+++ b/Modules/socketmodule.c	Tue Aug 17 15:30:23 2010 +0000
@@ -3822,8 +3822,10 @@
 
 /*ARGSUSED*/
 static PyObject *
-socket_getaddrinfo(PyObject *self, PyObject *args)
+socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
 {
+    static char* kwnames[] = {"host", "port", "family", "type", "proto", 
+                              "flags", 0};
     struct addrinfo hints, *res;
     struct addrinfo *res0 = NULL;
     PyObject *hobj = NULL;
@@ -3837,8 +3839,8 @@
 
     family = socktype = protocol = flags = 0;
     family = AF_UNSPEC;
-    if (!PyArg_ParseTuple(args, "OO|iiii:getaddrinfo",
-                          &hobj, &pobj, &family, &socktype,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|iiii:getaddrinfo", 
+                          kwnames, &hobj, &pobj, &family, &socktype,
                           &protocol, &flags)) {
         return NULL;
     }
@@ -4105,8 +4107,8 @@
     {"inet_ntop",               socket_inet_ntop,
      METH_VARARGS, inet_ntop_doc},
 #endif
-    {"getaddrinfo",             socket_getaddrinfo,
-     METH_VARARGS, getaddrinfo_doc},
+    {"getaddrinfo",             (PyCFunction)socket_getaddrinfo,
+     METH_VARARGS | METH_KEYWORDS, getaddrinfo_doc},
     {"getnameinfo",             socket_getnameinfo,
      METH_VARARGS, getnameinfo_doc},
     {"getdefaulttimeout",       (PyCFunction)socket_getdefaulttimeout,