From ef93b87f1c8606d3995c3428537ade6aebd567d1 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 13 Mar 2000 15:41:59 +0000 Subject: 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(). --- Objects/listobject.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index ff777a3..d77b546 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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) { -- cgit v0.12