Commit ef93b87f authored by Guido van Rossum's avatar Guido van Rossum

Added Christian Tismer's patch to allow list.append(a,b,c) back --

with a twist: you have to define NO_STRICT_LIST_APPEND manually
to enable multi-arg append().
parent 570575b1
......@@ -562,13 +562,27 @@ listinsert(self, args)
return ins(self, i, v);
}
/* Define NO_STRICT_LIST_APPEND to enable multi-argument append() */
#ifndef NO_STRICT_LIST_APPEND
#define PyArg_ParseTuple_Compat1 PyArg_ParseTuple
#else
#define PyArg_ParseTuple_Compat1(args, format, ret) \
( \
PyTuple_GET_SIZE(args) > 1 ? (*ret = args, 1) : \
PyTuple_GET_SIZE(args) == 1 ? (*ret = PyTuple_GET_ITEM(args, 0), 1) : \
PyArg_ParseTuple(args, format, ret) \
)
#endif
static PyObject *
listappend(self, args)
PyListObject *self;
PyObject *args;
{
PyObject *v;
if (!PyArg_ParseTuple(args, "O:append", &v))
if (!PyArg_ParseTuple_Compat1(args, "O:append", &v))
return NULL;
return ins(self, (int) self->ob_size, v);
}
......@@ -1326,7 +1340,7 @@ listindex(self, args)
int i;
PyObject *v;
if (!PyArg_ParseTuple(args, "O:index", &v))
if (!PyArg_ParseTuple_Compat1(args, "O:index", &v))
return NULL;
for (i = 0; i < self->ob_size; i++) {
if (PyObject_Compare(self->ob_item[i], v) == 0)
......@@ -1347,7 +1361,7 @@ listcount(self, args)
int i;
PyObject *v;
if (!PyArg_ParseTuple(args, "O:count", &v))
if (!PyArg_ParseTuple_Compat1(args, "O:count", &v))
return NULL;
for (i = 0; i < self->ob_size; i++) {
if (PyObject_Compare(self->ob_item[i], v) == 0)
......@@ -1366,7 +1380,7 @@ listremove(self, args)
int i;
PyObject *v;
if (!PyArg_ParseTuple(args, "O:remove", &v))
if (!PyArg_ParseTuple_Compat1(args, "O:remove", &v))
return NULL;
for (i = 0; i < self->ob_size; i++) {
if (PyObject_Compare(self->ob_item[i], v) == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment