diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-17 15:30:23 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-17 15:30:23 (GMT) |
commit | ccfb91c89f9d7515356f31fff4af4c5cbd5eef7a (patch) | |
tree | bec4fcc901fce3653e504c5f24ca0983f2e1e861 /Modules/socketmodule.c | |
parent | 67b21b7547feee634bbecafeb88606ff350c0d3c (diff) | |
download | cpython-ccfb91c89f9d7515356f31fff4af4c5cbd5eef7a.zip cpython-ccfb91c89f9d7515356f31fff4af4c5cbd5eef7a.tar.gz cpython-ccfb91c89f9d7515356f31fff4af4c5cbd5eef7a.tar.bz2 |
fix issue #8866: parameters passed to socket.getaddrinfo can now be specified as single keyword arguments.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index b1a616e..ea546da 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -3822,8 +3822,10 @@ socket_inet_ntop(PyObject *self, PyObject *args) /*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 @@ socket_getaddrinfo(PyObject *self, PyObject *args) 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 @@ static PyMethodDef socket_methods[] = { {"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, |