[PATCH] test: Make gen-threads work with python3
authorJesse Rosenthal <jrosenthal@jhu.edu>
Fri, 31 Oct 2014 17:33:25 +0000 (13:33 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:58 +0000 (10:05 -0800)
e7/0e32c2506da51ed7ba3d3c58743786a8726830 [new file with mode: 0644]

diff --git a/e7/0e32c2506da51ed7ba3d3c58743786a8726830 b/e7/0e32c2506da51ed7ba3d3c58743786a8726830
new file mode 100644 (file)
index 0000000..5a2b45a
--- /dev/null
@@ -0,0 +1,78 @@
+Return-Path: <prvs=374b26013=jrosenthal@jhu.edu>\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 36907431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 10:33:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] 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 yeClcEKzzHwo for <notmuch@notmuchmail.org>;\r
+       Fri, 31 Oct 2014 10:33:35 -0700 (PDT)\r
+Received: from smtpauth.johnshopkins.edu (smtpauth.johnshopkins.edu\r
+       [162.129.8.150]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 9CE73431FAF\r
+       for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 10:33:35 -0700 (PDT)\r
+X-IronPort-AV: E=Sophos;i="5.07,295,1413259200"; d="scan'208";a="110278986"\r
+Received: from guppy.hwcampus.jhu.edu (HELO localhost) ([10.161.32.234])\r
+       by IPEB2.johnshopkins.edu with ESMTP/TLS/AES128-SHA;\r
+       31 Oct 2014 13:33:33 -0400\r
+From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: Make gen-threads work with python3\r
+Date: Fri, 31 Oct 2014 13:33:25 -0400\r
+Message-Id: <1414776805-30000-1-git-send-email-jrosenthal@jhu.edu>\r
+X-Mailer: git-send-email 2.1.2\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, 31 Oct 2014 17:33:41 -0000\r
+\r
+python3 doesn't allow dictionaries to be initialized with non-string\r
+keywords. This presents problems on systems in which "python" means\r
+"python3". We instead initalize the dictionary using the dict\r
+comprehension and then update it with the values from the tree. This\r
+will work with both python2 and python3.\r
+---\r
+ test/gen-threads.py | 4 ++--\r
+ 1 file changed, 2 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/test/gen-threads.py b/test/gen-threads.py\r
+index 9fbb847..70fb1f6 100644\r
+--- a/test/gen-threads.py\r
++++ b/test/gen-threads.py\r
+@@ -2,7 +2,6 @@\r
+ # argv[1].  Each output line is a thread structure, where the n'th\r
+ # field is either a number giving the parent of message n or "None"\r
+ # for the root.\r
+-\r
+ import sys\r
+ from itertools import chain, combinations\r
\r
+@@ -28,6 +27,7 @@ while queue:\r
+     else:\r
+         # Expand node to_expand[0] with each possible set of children\r
+         for children in subsets(free):\r
+-            ntree = dict(tree, **{child: to_expand[0] for child in children})\r
++            ntree = {child: to_expand[0] for child in children}\r
++            ntree.update(tree)\r
+             nfree = free.difference(children)\r
+             queue.append((ntree, nfree, to_expand[1:] + tuple(children)))\r
+-- \r
+2.1.2\r
+\r