diff options
author | Guido van Rossum <guido@python.org> | 2000-03-13 15:41:59 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-13 15:41:59 (GMT) |
commit | ef93b87f1c8606d3995c3428537ade6aebd567d1 (patch) | |
tree | bc3e6122ad4f3225f7a3664061cd199202b7d19e /Objects | |
parent | 570575b1eec5f505ad40dd1e2690e4c433180364 (diff) | |
download | cpython-ef93b87f1c8606d3995c3428537ade6aebd567d1.zip cpython-ef93b87f1c8606d3995c3428537ade6aebd567d1.tar.gz cpython-ef93b87f1c8606d3995c3428537ade6aebd567d1.tar.bz2 |
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().
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/listobject.c | 22 |
1 files 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) { |