diff Modules/socketmodule.c @ 56109:58ba85c0d4b0 2.6

Merged revisions 74943 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74943 | georg.brandl | 2009-09-19 09:35:07 +0200 (Sa, 19 Sep 2009) | 1 line #6944: the argument to PyArg_ParseTuple should be a tuple, otherwise a SystemError is set. Also clean up another usage of PyArg_ParseTuple. ........
author Georg Brandl <georg@python.org>
date Sat, 19 Sep 2009 07:46:24 +0000
parents 6ddbdfdb7a86
children c78a00a1d6db
line wrap: on
line diff
--- a/Modules/socketmodule.c	Fri Sep 18 21:02:27 2009 +0000
+++ b/Modules/socketmodule.c	Sat Sep 19 07:46:24 2009 +0000
@@ -4060,8 +4060,13 @@
 	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));
@@ -4084,9 +4089,7 @@
 	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;