python: fix Message.get_filenames()
authorThomas Jost <schnouki@schnouki.net>
Fri, 30 Sep 2011 10:16:47 +0000 (12:16 +0200)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Fri, 30 Sep 2011 22:40:20 +0000 (00:40 +0200)
Previously, the Filenames generator only yielded *one* filename before
returning, making Message.get_filenames() behave as Message.get_filename(). This
commit fixes this incorrect behavior: now the generator yields all the
filenames, as expected.

bindings/python/notmuch/filename.py

index a16e717e778d80fa4c9236ad94249c10ce237ceb..de4d785ad6085ddfd3fbf42ebe54ae33d5ca76c7 100644 (file)
@@ -82,13 +82,11 @@ class Filenames(object):
         if self._files is None:
             raise NotmuchError(STATUS.NOT_INITIALIZED)
 
-        if not nmlib.notmuch_filenames_valid(self._files):
-            self._files = None
-            return
+        while nmlib.notmuch_filenames_valid(self._files):
+            yield Filenames._get(self._files)
+            nmlib.notmuch_filenames_move_to_next(self._files)
 
-        file = Filenames._get(self._files)
-        nmlib.notmuch_filenames_move_to_next(self._files)
-        yield file
+        self._files = None
 
     def __str__(self):
         """Represent Filenames() as newline-separated list of full paths