mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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().
This commit is contained in:
parent
570575b1ee
commit
ef93b87f1c
1 changed files with 18 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue