summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-05 09:08:28 (GMT)
committerGeorg Brandl <georg@python.org>2008-12-05 09:08:28 (GMT)
commitfa71a907031b9342c47eef17a840d0488063801c (patch)
tree808092f73be6610d1848e10623d12608093788f3 /Objects/listobject.c
parent5667280a07cc12691709e2b5ffa9ac7e3a0172ee (diff)
downloadcpython-fa71a907031b9342c47eef17a840d0488063801c.zip
cpython-fa71a907031b9342c47eef17a840d0488063801c.tar.gz
cpython-fa71a907031b9342c47eef17a840d0488063801c.tar.bz2
Merged revisions 67326,67498,67531-67532,67538,67553-67554,67556-67557 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67326 | benjamin.peterson | 2008-11-22 02:59:15 +0100 (Sat, 22 Nov 2008) | 1 line backport r67325: make FileIO.mode always contain 'b' ........ r67498 | raymond.hettinger | 2008-12-03 16:42:10 +0100 (Wed, 03 Dec 2008) | 1 line Backport r67478 ........ r67531 | georg.brandl | 2008-12-04 19:54:05 +0100 (Thu, 04 Dec 2008) | 2 lines Add reference to enumerate() to indices example. ........ r67532 | georg.brandl | 2008-12-04 19:59:16 +0100 (Thu, 04 Dec 2008) | 2 lines Add another heapq example. ........ r67538 | georg.brandl | 2008-12-04 22:28:16 +0100 (Thu, 04 Dec 2008) | 2 lines Clarification to avoid confusing output with file descriptors. ........ r67553 | georg.brandl | 2008-12-05 08:49:49 +0100 (Fri, 05 Dec 2008) | 2 lines #4408: document regex.groups. ........ r67554 | georg.brandl | 2008-12-05 08:52:26 +0100 (Fri, 05 Dec 2008) | 2 lines #4409: fix asterisks looking like footnotes. ........ r67556 | georg.brandl | 2008-12-05 09:02:17 +0100 (Fri, 05 Dec 2008) | 2 lines #4441: improve doc for os.open() flags. ........ r67557 | georg.brandl | 2008-12-05 09:06:57 +0100 (Fri, 05 Dec 2008) | 2 lines Add an index entry for "subclassing immutable types". ........
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index e8379e1..7b4bf35 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2911,11 +2911,11 @@ static PyObject *list_reversed(PyListObject *, PyObject *);
static void listreviter_dealloc(listreviterobject *);
static int listreviter_traverse(listreviterobject *, visitproc, void *);
static PyObject *listreviter_next(listreviterobject *);
-static Py_ssize_t listreviter_len(listreviterobject *);
+static PyObject *listreviter_len(listreviterobject *);
-static PySequenceMethods listreviter_as_sequence = {
- (lenfunc)listreviter_len, /* sq_length */
- 0, /* sq_concat */
+static PyMethodDef listreviter_methods[] = {
+ {"__length_hint__", (PyCFunction)listreviter_len, METH_NOARGS, length_hint_doc},
+ {NULL, NULL} /* sentinel */
};
PyTypeObject PyListRevIter_Type = {
@@ -2931,7 +2931,7 @@ PyTypeObject PyListRevIter_Type = {
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
- &listreviter_as_sequence, /* tp_as_sequence */
+ 0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
@@ -2947,6 +2947,7 @@ PyTypeObject PyListRevIter_Type = {
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)listreviter_next, /* tp_iternext */
+ listreviter_methods, /* tp_methods */
0,
};
@@ -3002,11 +3003,11 @@ listreviter_next(listreviterobject *it)
return NULL;
}
-static Py_ssize_t
+static PyObject *
listreviter_len(listreviterobject *it)
{
Py_ssize_t len = it->it_index + 1;
if (it->it_seq == NULL || PyList_GET_SIZE(it->it_seq) < len)
- return 0;
- return len;
+ len = 0;
+ return PyLong_FromSsize_t(len);
}