summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-02-17 23:16:43 (GMT)
committerGuido van Rossum <guido@python.org>1999-02-17 23:16:43 (GMT)
commit66368ccc558f9658617aa2a967261da98c153c09 (patch)
tree10671f4dbb72175f63561e664d547575c96a8dde /Python/getargs.c
parent127ed0a71e3875ec5bc6d0ea48572b2d0da54bc9 (diff)
downloadcpython-66368ccc558f9658617aa2a967261da98c153c09.zip
cpython-66368ccc558f9658617aa2a967261da98c153c09.tar.gz
cpython-66368ccc558f9658617aa2a967261da98c153c09.tar.bz2
Patch by Tommy Burnette to accept an arbitrary sequence when "(...)"
is used in the format string, instead of requiring a tuple. This is in line with the general trend towards accepting arbitrary sequences.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index dc852ae..2d9e2b7 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -357,27 +357,30 @@ converttuple(arg, p_format, p_va, levels, msgbuf, toplevel)
n++;
}
- if (!PyTuple_Check(arg)) {
+ if (!PySequence_Check(arg)) {
levels[0] = 0;
sprintf(msgbuf,
- toplevel ? "%d arguments, %s" : "%d-tuple, %s",
+ toplevel ? "%d arguments, %s" : "%d-sequence, %s",
n, arg == Py_None ? "None" : arg->ob_type->tp_name);
return msgbuf;
}
- if ((i = PyTuple_Size(arg)) != n) {
+ if ((i = PySequence_Length(arg)) != n) {
levels[0] = 0;
sprintf(msgbuf,
- toplevel ? "%d arguments, %d" : "%d-tuple, %d-tuple",
- n, i);
+ toplevel ? "%d arguments, %d" : "%d-sequence, %d-sequence",
+ n, i);
return msgbuf;
}
format = *p_format;
for (i = 0; i < n; i++) {
char *msg;
- msg = convertitem(PyTuple_GetItem(arg, i), &format, p_va,
- levels+1, msgbuf);
+ PyObject *item;
+ item = PySequence_GetItem(arg, i);
+ msg = convertitem(item, &format, p_va, levels+1, msgbuf);
+ /* PySequence_GetItem calls tp->sq_item, which INCREFs */
+ Py_XDECREF(item);
if (msg != NULL) {
levels[0] = i+1;
return msg;