[PATCH] python: fix Message.get_filenames()
authorThomas Jost <schnouki@schnouki.net>
Fri, 30 Sep 2011 10:16:47 +0000 (12:16 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:31 +0000 (09:39 -0800)
c0/e66323daa282aa4c2bd14cd8e826bdbbdfb362 [new file with mode: 0644]

diff --git a/c0/e66323daa282aa4c2bd14cd8e826bdbbdfb362 b/c0/e66323daa282aa4c2bd14cd8e826bdbbdfb362
new file mode 100644 (file)
index 0000000..ac7e674
--- /dev/null
@@ -0,0 +1,83 @@
+Return-Path: <schnouki@schnouki.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 98FFB431FD0\r
+       for <notmuch@notmuchmail.org>; Fri, 30 Sep 2011 03:17:05 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id Ao3TbxWQgW+d for <notmuch@notmuchmail.org>;\r
+       Fri, 30 Sep 2011 03:17:03 -0700 (PDT)\r
+Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
+       by olra.theworths.org (Postfix) with ESMTP id 6B067431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 30 Sep 2011 03:17:03 -0700 (PDT)\r
+Received: from localhost.localdomain (thor.loria.fr [152.81.12.250])\r
+       by ks3536.kimsufi.com (Postfix) with ESMTPSA id 1686E6A069B;\r
+       Fri, 30 Sep 2011 12:17:01 +0200 (CEST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
+       s=key-schnouki; t=1317377821;\r
+       bh=bNbNoZdA5DRCJR8sCBRtVdRRY67iYkU5mEXCnUpoUY8=;\r
+       h=From:To:Subject:Date:Message-Id;\r
+       b=XoVcF6XvD2SCl4S3qFbD+yhYQYyWAQPYbq401IyTDWCx+XPKQXwv6CV9REVqeeIuH\r
+       0qf7klkJPCuLnoyCGRWy/KoFhIDneo4o2WtVgjLsv+lsqOZYzkXy6Dw79kecnvwxTY\r
+       cGEfswcRyJC+Ja4I1HOB3QYOBRuB+7q5scFiBL30=\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] python: fix Message.get_filenames()\r
+Date: Fri, 30 Sep 2011 12:16:47 +0200\r
+Message-Id: <1317377807-20636-1-git-send-email-schnouki@schnouki.net>\r
+X-Mailer: git-send-email 1.7.6.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 30 Sep 2011 10:17:05 -0000\r
+\r
+Previously, the Filenames generator only yielded *one* filename before\r
+returning, making Message.get_filenames() behave as Message.get_filename(). This\r
+commit fixes this incorrect behavior: now the generator yields all the\r
+filenames, as expected.\r
+---\r
+ bindings/python/notmuch/filename.py |   10 ++++------\r
+ 1 files changed, 4 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/filename.py b/bindings/python/notmuch/filename.py\r
+index 630886d..b44d4c5 100644\r
+--- a/bindings/python/notmuch/filename.py\r
++++ b/bindings/python/notmuch/filename.py\r
+@@ -82,13 +82,11 @@ class Filenames(object):\r
+         if self._files is None:\r
+             raise NotmuchError(STATUS.NOT_INITIALIZED)\r
\r
+-        if not nmlib.notmuch_filenames_valid(self._files):\r
+-            self._files = None\r
+-            return\r
++        while nmlib.notmuch_filenames_valid(self._files):\r
++            yield Filenames._get(self._files)\r
++            nmlib.notmuch_filenames_move_to_next(self._files)\r
\r
+-        file = Filenames._get(self._files)\r
+-        nmlib.notmuch_filenames_move_to_next(self._files)\r
+-        yield file\r
++        self._files = None\r
\r
+     def __str__(self):\r
+         """Represent Filenames() as newline-separated list of full paths\r
+-- \r
+1.7.6.4\r
+\r