[Python-checkins] r74943 - in python/trunk: Lib/test/test_socket.py Misc/NEWS Modules/socketmodule.c
georg.brandl
python-checkins at python.org
Sat Sep 19 09:35:07 CEST 2009
Author: georg.brandl
Date: Sat Sep 19 09:35:07 2009
New Revision: 74943
Log:
#6944: the argument to PyArg_ParseTuple should be a tuple, otherwise a SystemError is set. Also clean up another usage of PyArg_ParseTuple.
Modified:
python/trunk/Lib/test/test_socket.py
python/trunk/Misc/NEWS
python/trunk/Modules/socketmodule.c
Modified: python/trunk/Lib/test/test_socket.py
==============================================================================
--- python/trunk/Lib/test/test_socket.py (original)
+++ python/trunk/Lib/test/test_socket.py Sat Sep 19 09:35:07 2009
@@ -281,7 +281,7 @@
# On some versions, this loses a reference
orig = sys.getrefcount(__name__)
socket.getnameinfo(__name__,0)
- except SystemError:
+ except TypeError:
if sys.getrefcount(__name__) <> orig:
self.fail("socket.getnameinfo loses a reference")
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sat Sep 19 09:35:07 2009
@@ -1333,6 +1333,9 @@
Extension Modules
-----------------
+- Issue #6944: Fix a SystemError when socket.getnameinfo() was called
+ with something other than a tuple as first argument.
+
- Issue #6865: Fix reference counting issue in the initialization of the pwd
module.
Modified: python/trunk/Modules/socketmodule.c
==============================================================================
--- python/trunk/Modules/socketmodule.c (original)
+++ python/trunk/Modules/socketmodule.c Sat Sep 19 09:35:07 2009
@@ -4100,8 +4100,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));
@@ -4124,9 +4129,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;
More information about the Python-checkins
mailing list