summaryrefslogtreecommitdiff
path: root/python/arfile.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-08-08 19:34:17 +0200
committerJulian Andres Klode <jak@debian.org>2009-08-08 19:34:17 +0200
commit58c1b550e9a96dbd1efcf42a8389b6819249aee5 (patch)
tree2099bf61254abe5aef0a03e7509864c44ddd482b /python/arfile.cc
parente4ea031d3338a6c9894b3bd4115fbb852c5f0eee (diff)
downloadpython-apt-58c1b550e9a96dbd1efcf42a8389b6819249aee5.tar.gz
python/arfile.cc: Make ArArchive iterable.
Diffstat (limited to 'python/arfile.cc')
-rw-r--r--python/arfile.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/python/arfile.cc b/python/arfile.cc
index 1185c16a..2eb6f1cd 100644
--- a/python/arfile.cc
+++ b/python/arfile.cc
@@ -289,6 +289,14 @@ static PyObject *ararchive_getnames(PyArArchiveObject *self)
return list;
}
+// Just run getmembers() and return an iterator over the list.
+static PyObject *ararchive_iter(PyArArchiveObject *self) {
+ PyObject *members = ararchive_getmembers(self);
+ PyObject *iter = PyObject_GetIter(members);
+ Py_DECREF(members);
+ return iter;
+}
+
PyMethodDef ararchive_methods[] = {
{"getmember",(PyCFunction)ararchive_getmember,METH_O,
ararchive_getmember_doc},
@@ -395,7 +403,7 @@ PyTypeObject PyArArchive_Type = {
CppOwnedClear<ARArchive*>, // tp_clear
0, // tp_richcompare
0, // tp_weaklistoffset
- 0, // tp_iter
+ (getiterfunc)ararchive_iter, // tp_iter
0, // tp_iternext
ararchive_methods, // tp_methods
0, // tp_members