[pypy-svn] pypy fast-forward: Revert the limitation of tuples-only, now that PyPy_Borrow() is used.

arigo commits-noreply at bitbucket.org
Sun Dec 19 11:52:27 CET 2010


Author: Armin Rigo <arigo at tunes.org>
Branch: fast-forward
Changeset: r40123:8c2427fa1a01
Date: 2010-12-18 13:02 +0100
http://bitbucket.org/pypy/pypy/changeset/8c2427fa1a01/

Log:	Revert the limitation of tuples-only, now that PyPy_Borrow() is used.

diff --git a/pypy/module/cpyext/src/getargs.c b/pypy/module/cpyext/src/getargs.c
--- a/pypy/module/cpyext/src/getargs.c
+++ b/pypy/module/cpyext/src/getargs.c
@@ -445,23 +445,20 @@
 	for (i = 0; i < n; i++) {
 		char *msg;
 		PyObject *item;
-		/* CPython uses PySequence_GetItem() and Py_XDECREF() here,
-		   exposing a crash (see http://bugs.python.org/issue6083).
-		   It always crashes with PyPy, so we apply the fix being
-		   discussed: we only allow a tuple. */
-		item = PyTuple_GetItem(arg, i);
+        item = PySequence_GetItem(arg, i);
 		if (item == NULL) {
 			PyErr_Clear();
 			levels[0] = i+1;
 			levels[1] = 0;
-			strncpy(msgbuf, "is not retrievable (subargument "
-				        "must be a real tuple with PyPy)",
+			strncpy(msgbuf, "is not retrievable",
 				        bufsize);
 			return msgbuf;
 		}
                 PyPy_Borrow(arg, item);
 		msg = convertitem(item, &format, p_va, flags, levels+1, 
 				  msgbuf, bufsize, freelist);
+        /* PySequence_GetItem calls tp->sq_item, which INCREFs */
+        Py_XDECREF(item);
 		if (msg != NULL) {
 			levels[0] = i+1;
 			return msg;


More information about the Pypy-commit mailing list