summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/concrete.rst
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2015-12-20 03:31:10 (GMT)
committerLarry Hastings <larry@hastings.org>2015-12-20 03:31:10 (GMT)
commitfa7193286099f8e4164f4a795afd5ad4a8e229df (patch)
tree46bfb40d4c7364def25461547d8d0657ee560196 /Doc/c-api/concrete.rst
parent5caf39d82745b4fdd3158a938497579e3c45f9c2 (diff)
downloadcpython-3.4.4.zip
cpython-3.4.4.tar.gz
cpython-3.4.4.tar.bz2
Release bump for Python 3.4.4 final.v3.4.4
Diffstat (limited to 'Doc/c-api/concrete.rst')
0 files changed, 0 insertions, 0 deletions
>-rw-r--r--Objects/fileobject.c53
-rw-r--r--Objects/iterobject.c4
-rw-r--r--Objects/listobject.c57
-rw-r--r--Objects/methodobject.c33
-rw-r--r--Objects/rangeobject.c5
-rw-r--r--Objects/stringobject.c159
-rw-r--r--Objects/typeobject.c6
-rw-r--r--Objects/unicodeobject.c176
-rw-r--r--Python/bltinmodule.c159
-rw-r--r--Python/ceval.c73
-rw-r--r--Python/sysmodule.c74
-rwxr-xr-xconfigure2
17 files changed, 430 insertions, 552 deletions
diff --git a/Doc/api/api.tex b/Doc/api/api.tex
index adcb280..894e5b6 100644
--- a/Doc/api/api.tex
+++ b/Doc/api/api.tex
@@ -5257,6 +5257,68 @@ structure has four fields:
\end{tableiii}
\end{ctypedesc}
+The \var{ml_meth} is a C function pointer. The functions may be of
+different types, but they always return \ctype{PyObject*}. If the
+function is not of the \ctype{PyCFunction}, the compiler will require
+a cast in the method table. Even though \ctype{PyCFunction} defines
+the first parameter as \ctype{PyObject*}, it is common that the method
+implementation uses a the specific C type of the \var{self} object.
+
+The flags can have the following values. Only METH_VARARGS and
+METH_KEYWORDS can be combined; the others can't.
+
+\begin{datadesc}{METH_VARARGS}
+
+This is the typical calling convention, where the methods have the
+type \ctype{PyMethodDef}. The function expects two \ctype{PyObject*}.
+The first one is the \var{self} object for methods; for module
+functions, it has the value given to \cfunction{PyInitModule4} (or
+\NULL{} if \cfunction{PyInitModule} was used). The second parameter
+(often called \var{args}) is a tuple object representing all
+arguments. This parameter is typically processed using
+\cfunction{PyArg_ParseTuple}.
+
+\end{datadesc}
+
+\begin{datadesc}{METH_KEYWORDS}
+
+Methods with these flags must be of type
+\ctype{PyCFunctionWithKeywords}. The function expects three
+parameters: \var{self}, \var{args}, and a dictionary of all the keyword
+arguments. The flag is typically combined with METH_VARARGS, and the
+parameters are typically processed using
+\cfunction{PyArg_ParseTupleAndKeywords}.
+
+\end{datadesc}
+
+\begin{datadesc}{METH_NOARGS}
+
+Methods without parameters don't need to check whether arguments are
+given if they are listed with the \code{METH_NOARGS} flag. They need
+to be of type \ctype{PyNoArgsFunction}, i.e. they expect a single
+\var{self} parameter.
+
+\end{datadesc}
+
+\begin{datadesc}{METH_O}
+
+Methods with a single object argument can be listed with the
+\code{METH_O} flag, instead of invoking \cfunction{PyArg_ParseTuple}
+with a \code{``O''} argument. They have the type \ctype{PyCFunction},
+with the \var{self} parameter, and a \ctype{PyObject*} parameter
+representing the single argument.
+
+\end{datadesc}
+
+\begin{datadesc}{METH_OLDARGS}
+
+This calling convention is deprecated. The method must be of type
+\ctype{PyCFunction}. The second argument is \NULL{} if no arguments
+are given, a single object if exactly one argument is given, and a
+tuple of objects if more than one argument is given.
+
+\end{datadesc}
+
\begin{cfuncdesc}{PyObject*}{Py_FindMethod}{PyMethodDef[] table,
PyObject *ob, char *name}
Return a bound method object for an extension type implemented in C.
diff --git a/Misc/NEWS b/Misc/NEWS
index 7648e3f..6bcf2e4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -90,6 +90,12 @@ Core
(These warnings currently don't conform to the warnings framework of
PEP 230; we intend to fix this in 2.2a2.)
+- Two new flags METH_NOARGS and METH_O are available in method definition
+ tables to simplify implementation of methods with no arguments and a
+ single untyped argument. Calling such methods is more efficient than
+ calling corresponding METH_VARARGS methods. METH_OLDARGS is now
+ deprecated.
+
- The UTF-16 codec was modified to be more RFC compliant. It will now
only remove BOM characters at the start of the string and then
only if running in native mode (UTF-16-LE and -BE won't remove a
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 5cfb3ca..84eee11 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -580,18 +580,16 @@ complex_float(PyObject *v)
}
static PyObject *
-complex_conjugate(PyObject *self, PyObject *args)
+complex_conjugate(PyObject *self)
{
Py_complex c;
- if (!PyArg_ParseTuple(args, ":conjugate"))
- return NULL;
c = ((PyComplexObject *)self)->cval;
c.imag = -c.imag;
return PyComplex_FromCComplex(c);
}
static PyMethodDef complex_methods[] = {
- {"conjugate", complex_conjugate, 1},
+ {"conjugate", (PyCFunction)complex_conjugate, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index a2ecde5..facd1c4 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -601,12 +601,8 @@ static PySequenceMethods proxy_as_sequence = {
};
static PyObject *
-proxy_has_key(proxyobject *pp, PyObject *args)
+proxy_has_key(proxyobject *pp, PyObject *key)
{
- PyObject *key;
-
- if (!PyArg_ParseTuple(args, "O:has_key", &key))
- return NULL;
return PyInt_FromLong(PySequence_Contains(pp->dict, key));
}
@@ -621,44 +617,36 @@ proxy_get(proxyobject *pp, PyObject *args)
}
static PyObject *
-proxy_keys(proxyobject *pp, PyObject *args)
+proxy_keys(proxyobject *pp)
{
- if (!PyArg_ParseTuple(args, ":keys"))
- return NULL;
return PyMapping_Keys(pp->dict);
}
static PyObject *
-proxy_values(proxyobject *pp, PyObject *args)
+proxy_values(proxyobject *pp)
{
- if (!PyArg_ParseTuple(args, ":values"))
- return NULL;
return PyMapping_Values(pp->dict);
}
static PyObject *
-proxy_items(proxyobject *pp, PyObject *args)
+proxy_items(proxyobject *pp)
{
- if (!PyArg_ParseTuple(args, ":items"))
- return NULL;
return PyMapping_Items(pp->dict);
}
static PyObject *
-proxy_copy(proxyobject *pp, PyObject *args)
+proxy_copy(proxyobject *pp)
{
- if (!PyArg_ParseTuple(args, ":copy"))
- return NULL;
return PyObject_CallMethod(pp->dict, "copy", NULL);
}
static PyMethodDef proxy_methods[] = {
- {"has_key", (PyCFunction)proxy_has_key, METH_VARARGS, "XXX"},
+ {"has_key", (PyCFunction)proxy_has_key, METH_O, "XXX"},
{"get", (PyCFunction)proxy_get, METH_VARARGS, "XXX"},
- {"keys", (PyCFunction)proxy_keys, METH_VARARGS, "XXX"},
- {"values", (PyCFunction)proxy_values, METH_VARARGS, "XXX"},
- {"items", (PyCFunction)proxy_items, METH_VARARGS, "XXX"},
- {"copy", (PyCFunction)proxy_copy, METH_VARARGS, "XXX"},
+ {"keys", (PyCFunction)proxy_keys, METH_NOARGS, "XXX"},
+ {"values", (PyCFunction)proxy_values, METH_NOARGS, "XXX"},
+ {"items", (PyCFunction)proxy_items, METH_NOARGS, "XXX"},
+ {"copy", (PyCFunction)proxy_copy, METH_NOARGS, "XXX"},
{0}
};
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 73c459f..ab5f4b5 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -875,13 +875,11 @@ static PyMappingMethods dict_as_mapping = {
};
static PyObject *
-dict_keys(register dictobject *mp, PyObject *args)
+dict_keys(register dictobject *mp)
{
register PyObject *v;
register int i, j, n;
- if (!PyArg_NoArgs(args))
- return NULL;
again:
n = mp->ma_used;
v = PyList_New(n);
@@ -906,13 +904,11 @@ dict_keys(register dictobject *mp, PyObject *args)
}
static PyObject *
-dict_values(register dictobject *mp, PyObject *args)
+dict_values(register dictobject *mp)
{
register PyObject *v;
register int i, j, n;
- if (!PyArg_NoArgs(args))
- return NULL;
again:
n = mp->ma_used;
v = PyList_New(n);
@@ -937,14 +933,12 @@ dict_values(register dictobject *mp, PyObject *args)
}
static PyObject *
-dict_items(register dictobject *mp, PyObject *args)
+dict_items(register dictobject *mp)
{
register PyObject *v;
register int i, j, n;
PyObject *item, *key, *value;
- if (!PyArg_NoArgs(args))
- return NULL;
/* Preallocate the list of tuples, to avoid allocations during
* the loop over the items, which could trigger GC, which
* could resize the dict. :-(
@@ -987,12 +981,8 @@ dict_items(register dictobject *mp, PyObject *args)
}
static PyObject *
-dict_update(PyObject *mp, PyObject *args)
+dict_update(PyObject *mp, PyObject *other)
{
- PyObject *other;
-
- if (!PyArg_ParseTuple(args, "O:update", &other))
- return NULL;
if (PyDict_Update(mp, other) < 0)
return NULL;
Py_INCREF(Py_None);
@@ -1099,10 +1089,8 @@ PyDict_Merge(PyObject *a, PyObject *b, int override)
}
static PyObject *
-dict_copy(register dictobject *mp, PyObject *args)
+dict_copy(register dictobject *mp)
{
- if (!PyArg_Parse(args, ""))
- return NULL;
return PyDict_Copy((PyObject*)mp);
}
@@ -1155,7 +1143,7 @@ PyDict_Keys(PyObject *mp)
PyErr_BadInternalCall();
return NULL;
}
- return dict_keys((dictobject *)mp, (PyObject *)NULL);
+ return dict_keys((dictobject *)mp);
}
PyObject *
@@ -1165,7 +1153,7 @@ PyDict_Values(PyObject *mp)
PyErr_BadInternalCall();
return NULL;
}
- return dict_values((dictobject *)mp, (PyObject *)NULL);
+ return dict_values((dictobject *)mp);
}
PyObject *
@@ -1175,7 +1163,7 @@ PyDict_Items(PyObject *mp)
PyErr_BadInternalCall();
return NULL;
}
- return dict_items((dictobject *)mp, (PyObject *)NULL);
+ return dict_items((dictobject *)mp);
}
/* Subroutine which returns the smallest key in a for which b's value
@@ -1366,13 +1354,10 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
}
static PyObject *
-dict_has_key(register dictobject *mp, PyObject *args)
+dict_has_key(register dictobject *mp, PyObject *key)
{
- PyObject *key;
long hash;
register long ok;
- if (!PyArg_ParseTuple(args, "O:has_key", &key))
- return NULL;
#ifdef CACHE_HASH
if (!PyString_Check(key) ||
(hash = ((PyStringObject *) key)->ob_shash) == -1)
@@ -1447,24 +1432,20 @@ dict_setdefault(register dictobject *mp, PyObject *args)
static PyObject *
-dict_clear(register dictobject *mp, PyObject *args)
+dict_clear(register dictobject *mp)
{
- if (!PyArg_NoArgs(args))
- return NULL;
PyDict_Clear((PyObject *)mp);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
-dict_popitem(dictobject *mp, PyObject *args)
+dict_popitem(dictobject *mp)
{
int i = 0;
dictentry *ep;
PyObject *res;
- if (!PyArg_NoArgs(args))
- return NULL;
/* Allocate the result tuple before checking the size. Believe it
* or not, this allocation could trigger a garbage collection which
* could empty the dict, so if we checked the size first and that
@@ -1573,26 +1554,20 @@ select_item(PyObject *key, PyObject *value)
}
static PyObject *
-dict_iterkeys(dictobject *dict, PyObject *args)
+dict_iterkeys(dictobject *dict)
{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
return dictiter_new(dict, select_key);
}
static PyObject *
-dict_itervalues(dictobject *dict, PyObject *args)
+dict_itervalues(dictobject *dict)
{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
return dictiter_new(dict, select_value);
}
static PyObject *
-dict_iteritems(dictobject *dict, PyObject *args)
+dict_iteritems(dictobject *dict)
{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
return dictiter_new(dict, select_item);
}
@@ -1638,31 +1613,31 @@ static char iteritems__doc__[] =
"D.iteritems() -> an iterator over the (key, value) items of D";
static PyMethodDef mapp_methods[] = {
- {"has_key", (PyCFunction)dict_has_key, METH_VARARGS,
+ {"has_key", (PyCFunction)dict_has_key, METH_O,
has_key__doc__},
{"get", (PyCFunction)dict_get, METH_VARARGS,
get__doc__},
{"setdefault", (PyCFunction)dict_setdefault, METH_VARARGS,
setdefault_doc__},
- {"popitem", (PyCFunction)dict_popitem, METH_OLDARGS,
+ {"popitem", (PyCFunction)dict_popitem, METH_NOARGS,
popitem__doc__},
- {"keys", (PyCFunction)dict_keys, METH_OLDARGS,
+ {"keys", (PyCFunction)dict_keys, METH_NOARGS,
keys__doc__},
- {"items", (PyCFunction)dict_items, METH_OLDARGS,
+ {"items", (PyCFunction)dict_items, METH_NOARGS,
items__doc__},
- {"values", (PyCFunction)dict_values, METH_OLDARGS,
+ {"values", (PyCFunction)dict_values, METH_NOARGS,
values__doc__},
- {"update", (PyCFunction)dict_update, METH_VARARGS,
+ {"update", (PyCFunction)dict_update, METH_O,
update__doc__},
- {"clear", (PyCFunction)dict_clear, METH_OLDARGS,
+ {"clear", (PyCFunction)dict_clear, METH_NOARGS,
clear__doc__},
- {"copy", (PyCFunction)dict_copy, METH_OLDARGS,
+ {"copy", (PyCFunction)dict_copy, METH_NOARGS,
copy__doc__},
- {"iterkeys", (PyCFunction)dict_iterkeys, METH_VARARGS,
+ {"iterkeys", (PyCFunction)dict_iterkeys, METH_NOARGS,
iterkeys__doc__},
- {"itervalues", (PyCFunction)dict_itervalues, METH_VARARGS,
+ {"itervalues", (PyCFunction)dict_itervalues, METH_NOARGS,
itervalues__doc__},
- {"iteritems", (PyCFunction)dict_iteritems, METH_VARARGS,
+ {"iteritems", (PyCFunction)dict_iteritems, METH_NOARGS,
iteritems__doc__},
{NULL, NULL} /* sentinel */
};
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 946d41c..0bb2f25 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -189,11 +189,9 @@ file_repr(PyFileObject *f)
}
static PyObject *
-file_close(PyFileObject *f, PyObject *args)
+file_close(PyFileObject *f)
{
int sts = 0;
- if (!PyArg_NoArgs(args))
- return NULL;
if (f->f_fp != NULL) {
if (f->f_close != NULL) {
Py_BEGIN_ALLOW_THREADS
@@ -386,14 +384,12 @@ onioerror:
#endif /* HAVE_FTRUNCATE */
static PyObject *
-file_tell(PyFileObject *f, PyObject *args)
+file_tell(PyFileObject *f)
{
Py_off_t pos;
if (f->f_fp == NULL)
return err_closed();
- if (!PyArg_NoArgs(args))
- return NULL;
Py_BEGIN_ALLOW_THREADS
errno = 0;
pos = _portable_ftell(f->f_fp);
@@ -411,24 +407,20 @@ file_tell(PyFileObject *f, PyObject *args)
}
static PyObject *
-file_fileno(PyFileObject *f, PyObject *args)
+file_fileno(PyFileObject *f)
{
if (f->f_fp == NULL)
return err_closed();
- if (!PyArg_NoArgs(args))
- return NULL;
return PyInt_FromLong((long) fileno(f->f_fp));
}
static PyObject *
-file_flush(PyFileObject *f, PyObject *args)
+file_flush(PyFileObject *f)
{
int res;
if (f->f_fp == NULL)
return err_closed();
- if (!PyArg_NoArgs(args))
- return NULL;
Py_BEGIN_ALLOW_THREADS
errno = 0;
res = fflush(f->f_fp);
@@ -443,13 +435,11 @@ file_flush(PyFileObject *f, PyObject *args)
}
static PyObject *
-file_isatty(PyFileObject *f, PyObject *args)
+file_isatty(PyFileObject *f)
{
long res;
if (f->f_fp == NULL)
return err_closed();
- if (!PyArg_NoArgs(args))
- return NULL;
Py_BEGIN_ALLOW_THREADS
res = isatty((int)fileno(f->f_fp));
Py_END_ALLOW_THREADS
@@ -968,13 +958,10 @@ file_readline(PyFileObject *f, PyObject *args)
}
static PyObject *
-file_xreadlines(PyFileObject *f, PyObject *args)
+file_xreadlines(PyFileObject *f)
{
static PyObject* xreadlines_function = NULL;
- if (!PyArg_ParseTuple(args, ":xreadlines"))
- return NULL;
-
if (!xreadlines_function) {
PyObject *xreadlines_module =
PyImport_ImportModule("xreadlines");
@@ -1248,22 +1235,22 @@ file_writelines(PyFileObject *f, PyObject *args)
}
static PyMethodDef file_methods[] = {
- {"readline", (PyCFunction)file_readline, 1},
- {"read", (PyCFunction)file_read, 1},
- {"write", (PyCFunction)file_write, 0},
- {"fileno", (PyCFunction)file_fileno, 0},
- {"seek", (PyCFunction)file_seek, 1},
+ {"readline", (PyCFunction)file_readline, METH_VARARGS},
+ {"read", (PyCFunction)file_read, METH_VARARGS},
+ {"write", (PyCFunction)file_write, METH_OLDARGS},
+ {"fileno", (PyCFunction)file_fileno, METH_NOARGS},
+ {"seek", (PyCFunction)file_seek, METH_VARARGS},
#ifdef HAVE_FTRUNCATE
- {"truncate", (PyCFunction)file_truncate, 1},
+ {"truncate", (PyCFunction)file_truncate, METH_VARARGS},
#endif
- {"tell", (PyCFunction)file_tell, 0},
- {"readinto", (PyCFunction)file_readinto, 0},
- {"readlines", (PyCFunction)file_readlines, 1},
- {"xreadlines", (PyCFunction)file_xreadlines, 1},
- {"writelines", (PyCFunction)file_writelines, 0},
- {"flush", (PyCFunction)file_flush, 0},
- {"close", (PyCFunction)file_close, 0},
- {"isatty", (PyCFunction)file_isatty, 0},
+ {"tell", (PyCFunction)file_tell, METH_NOARGS},
+ {"readinto", (PyCFunction)file_readinto, METH_OLDARGS},
+ {"readlines", (PyCFunction)file_readlines, METH_VARARGS},
+ {"xreadlines", (PyCFunction)file_xreadlines, METH_NOARGS},
+ {"writelines", (PyCFunction)file_writelines, METH_O},
+ {"flush", (PyCFunction)file_flush, METH_NOARGS},
+ {"close", (PyCFunction)file_close, METH_NOARGS},
+ {"isatty", (PyCFunction)file_isatty, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index e062c8a..5783d20 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -37,7 +37,7 @@ iter_traverse(seqiterobject *it, visitproc visit, void *arg)
}
static PyObject *
-iter_next(seqiterobject *it, PyObject *args)
+iter_next(seqiterobject *it)
{
PyObject *seq = it->it_seq;
PyObject *result = PySequence_GetItem(seq, it->it_index++);
@@ -91,7 +91,7 @@ iter_iternext(PyObject *iterator)
}
static PyMethodDef iter_methods[] = {
- {"next", (PyCFunction)iter_next, METH_VARARGS,
+ {"next", (PyCFunction)iter_next, METH_NOARGS,
"it.next() -- get the next value, or raise StopIteration"},
{NULL, NULL} /* sentinel */
};
diff --git a/Objects/listobject.c b/Objects/listobject.c
index b77cc0a..c45cf75 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -623,11 +623,8 @@ listinsert(PyListObject *self, PyObject *args)
}
static PyObject *
-listappend(PyListObject *self, PyObject *args)
+listappend(PyListObject *self, PyObject *v)
{
- PyObject *v;
- if (!PyArg_ParseTuple(args, "O:append", &v))
- return NULL;
return ins(self, (int) self->ob_size, v);
}
@@ -702,14 +699,9 @@ list_inplace_concat(PyListObject *self, PyObject *other)
}
static PyObject *
-listextend(PyListObject *self, PyObject *args)
+listextend(PyListObject *self, PyObject *b)
{
- PyObject *b;
-
- if (!PyArg_ParseTuple(args, "O:extend", &b))
- return NULL;
-
b = PySequence_Fast(b, "list.extend() argument must be iterable");
if (!b)
return NULL;
@@ -1344,10 +1336,8 @@ _listreverse(PyListObject *self)
}
static PyObject *
-listreverse(PyListObject *self, PyObject *args)
+listreverse(PyListObject *self)
{
- if (!PyArg_ParseTuple(args, ":reverse"))
- return NULL;
_listreverse(self);
Py_INCREF(Py_None);
return Py_None;
@@ -1390,13 +1380,10 @@ PyList_AsTuple(PyObject *v)
}
static PyObject *
-listindex(PyListObject *self, PyObject *args)
+listindex(PyListObject *self, PyObject *v)
{
int i;
- PyObject *v;
- if (!PyArg_ParseTuple(args, "O:index", &v))
- return NULL;
for (i = 0; i < self->ob_size; i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0)
@@ -1409,14 +1396,11 @@ listindex(PyListObject *self, PyObject *args)
}
static PyObject *
-listcount(PyListObject *self, PyObject *args)
+listcount(PyListObject *self, PyObject *v)
{
int count = 0;
int i;
- PyObject *v;
- if (!PyArg_ParseTuple(args, "O:count", &v))
- return NULL;
for (i = 0; i < self->ob_size; i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0)
@@ -1428,13 +1412,10 @@ listcount(PyListObject *self, PyObject *args)
}
static PyObject *
-listremove(PyListObject *self, PyObject *args)
+listremove(PyListObject *self, PyObject *v)
{
int i;
- PyObject *v;
- if (!PyArg_ParseTuple(args, "O:remove", &v))
- return NULL;
for (i = 0; i < self->ob_size; i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0) {
@@ -1661,14 +1642,14 @@ static char sort_doc[] =
"L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1";
static PyMethodDef list_methods[] = {
- {"append", (PyCFunction)listappend, METH_VARARGS, append_doc},
+ {"append", (PyCFunction)listappend, METH_O, append_doc},
{"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc},
- {"extend", (PyCFunction)listextend, METH_VARARGS, extend_doc},
+ {"extend", (PyCFunction)listextend, METH_O, extend_doc},
{"pop", (PyCFunction)listpop, METH_VARARGS, pop_doc},
- {"remove", (PyCFunction)listremove, METH_VARARGS, remove_doc},
- {"index", (PyCFunction)listindex, METH_VARARGS, index_doc},
- {"count", (PyCFunction)listcount, METH_VARARGS, count_doc},
- {"reverse", (PyCFunction)listreverse, METH_VARARGS, reverse_doc},
+ {"remove", (PyCFunction)listremove, METH_O, remove_doc},
+ {"index", (PyCFunction)listindex, METH_O, index_doc},
+ {"count", (PyCFunction)listcount, METH_O, count_doc},
+ {"reverse", (PyCFunction)listreverse, METH_NOARGS, reverse_doc},
{"sort", (PyCFunction)listsort, METH_VARARGS, sort_doc},
{NULL, NULL} /* sentinel */
};
@@ -1749,13 +1730,13 @@ immutable_list_op(void)
}
static PyMethodDef immutable_list_methods[] = {
- {"append", (PyCFunction)immutable_list_op},
- {"insert", (PyCFunction)immutable_list_op},
- {"remove", (PyCFunction)immutable_list_op},
- {"index", (PyCFunction)listindex},
- {"count", (PyCFunction)listcount},
- {"reverse", (PyCFunction)immutable_list_op},
- {"sort", (PyCFunction)immutable_list_op},
+ {"append", (PyCFunction)immutable_list_op, METH_VARARGS},
+ {"insert", (PyCFunction)immutable_list_op, METH_VARARGS},
+ {"remove", (PyCFunction)immutable_list_op, METH_VARARGS},
+ {"index", (PyCFunction)listindex, METH_O},
+ {"count", (PyCFunction)listcount, METH_O},
+ {"reverse", (PyCFunction)immutable_list_op, METH_VARARGS},
+ {"sort", (PyCFunction)immutable_list_op, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Objects/methodobject.c b/Objects/methodobject.c