From 969efbf5751a0e1e2ed5e0b777f06dbe22967653 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 1 Nov 2014 10:08:26 +0200 Subject: [PATCH] Re: [PATCH] test: Make gen-threads work with python3 --- e6/672a9ff4a758b46c346b62219359212ad2116f | 131 ++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 e6/672a9ff4a758b46c346b62219359212ad2116f diff --git a/e6/672a9ff4a758b46c346b62219359212ad2116f b/e6/672a9ff4a758b46c346b62219359212ad2116f new file mode 100644 index 000000000..b53d6da3c --- /dev/null +++ b/e6/672a9ff4a758b46c346b62219359212ad2116f @@ -0,0 +1,131 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id E5850431FD0 + for ; Sat, 1 Nov 2014 01:08:58 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id trZ97GScag9U for ; + Sat, 1 Nov 2014 01:08:48 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id B5F98431FAF + for ; Sat, 1 Nov 2014 01:08:48 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id DAEF31000E0; + Sat, 1 Nov 2014 10:08:26 +0200 (EET) +From: Tomi Ollila +To: "W. Trevor King" , Jesse Rosenthal +Subject: Re: [PATCH] test: Make gen-threads work with python3 +In-Reply-To: <20141031174153.GQ15443@odin.tremily.us> +References: <1414776805-30000-1-git-send-email-jrosenthal@jhu.edu> + <20141031174153.GQ15443@odin.tremily.us> +User-Agent: Notmuch/0.18.1+130~ga61922f (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 01 Nov 2014 08:08:59 -0000 + +On Fri, Oct 31 2014, "W. Trevor King" wrote: + +> On Fri, Oct 31, 2014 at 01:33:25PM -0400, Jesse Rosenthal wrote: +>> We instead initalize the dictionary using the dict comprehension and +>> then update it with the values from the tree. This will work with +>> both python2 and python3. +> +> Dict comprehensions are new in 2.7 [1,2], so this drops support for +> systems where =E2=80=98python=E2=80=99 means =E2=80=98python2.6=E2=80=99.= + Personally, I'm fine with +> that, but I thought I'd point it out in case 2.6 users wanted to push +> back ;). + +Thanks Trevor. The original changed line: + +- ntree =3D dict(tree, **{child: to_expand[0] for child in children}) + +is already incompatible with python 2.6, so this doesn't change the current= +=20 +status quo there. + +The above changed to=20 + ++ ntree =3D dict(tree, **dict((child, to_expand[0]) for child in children)) + +works in Python 2.6 (if anyone interested), and it looks the change in this +patch is not difficult to make work in python 2.6 in case anyone +desires to do so... + +Although I have ready-made patch to make the former code work in python 2.6 +I've thought that maybe it is just unnecessary burden to support python 2.6 +there -- so that people can concentrate on improving tests instead... + +Therefore, +1 for this patch, provided that it works as expected. + +Tomi + + +> +>> diff --git a/test/gen-threads.py b/test/gen-threads.py +>> index 9fbb847..70fb1f6 100644 +>> --- a/test/gen-threads.py +>> +++ b/test/gen-threads.py +>> @@ -2,7 +2,6 @@ +>> # argv[1]. Each output line is a thread structure, where the n'th +>> # field is either a number giving the parent of message n or "None" +>> # for the root. +>> - +>> import sys +> +> Why remove this blank line? +> +>> from itertools import chain, combinations +>>=20=20 +>> @@ -28,6 +27,7 @@ while queue: +>> else: +>> # Expand node to_expand[0] with each possible set of children +>> for children in subsets(free): +>> - ntree =3D dict(tree, **{child: to_expand[0] for child in ch= +ildren}) +>> + ntree =3D {child: to_expand[0] for child in children} +>> + ntree.update(tree) +> +> This looks good to me. +> +> Cheers, +> Trevor +> +> [1]: https://docs.python.org/3/whatsnew/2.7.html#other-language-changes +> [2]: http://legacy.python.org/dev/peps/pep-0274/ +> +> --=20 +> This email may be signed or encrypted with GnuPG (http://www.gnupg.org). +> For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2