summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-09-19 07:35:07 (GMT)
committerGeorg Brandl <georg@python.org>2009-09-19 07:35:07 (GMT)
commitab849891ef1d96c4f770fbd256b2436359146f03 (patch)
treea201a3732f3180a1a7093c84f3eb41440cedfcad /Modules/socketmodule.c
parent9db5540ec46d5163231de8ddc574c215b2384753 (diff)
downloadcpython-ab849891ef1d96c4f770fbd256b2436359146f03.zip
cpython-ab849891ef1d96c4f770fbd256b2436359146f03.tar.gz
cpython-ab849891ef1d96c4f770fbd256b2436359146f03.tar.bz2
#6944: the argument to PyArg_ParseTuple should be a tuple, otherwise a SystemError is set. Also clean up another usage of PyArg_ParseTuple.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 5575855..18cce69 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4100,8 +4100,13 @@ socket_getnameinfo(PyObject *self, PyObject *args)
flags = flowinfo = scope_id = 0;
if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags))
return NULL;
- if (!PyArg_ParseTuple(sa, "si|ii",
- &hostp, &port, &flowinfo, &scope_id))
+ if (!PyTuple_Check(sa)) {
+ PyErr_SetString(PyExc_TypeError,
+ "getnameinfo() argument 1 must be a tuple");
+ return NULL;
+ }
+ if (!PyArg_ParseTuple(sa, "si|ii",
+ &hostp, &port, &flowinfo, &scope_id))
return NULL;
PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
memset(&hints, 0, sizeof(hints));
@@ -4124,9 +4129,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
switch (res->ai_family) {
case AF_INET:
{
- char *t1;
- int t2;
- if (PyArg_ParseTuple(sa, "si", &t1, &t2) == 0) {
+ if (PyTuple_GET_SIZE(sa) != 2) {
PyErr_SetString(socket_error,
"IPv4 sockaddr must be 2 tuple");
goto fail;