[PATCH] test: Make gen-threads work with python3
W. Trevor King
wking at tremily.us
Fri Oct 31 10:41:54 PDT 2014
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 ‘python’ means ‘python2.6’. Personally, I'm fine with
that, but I thought I'd point it out in case 2.6 users wanted to push
back ;).
> 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
>
> @@ -28,6 +27,7 @@ while queue:
> else:
> # Expand node to_expand[0] with each possible set of children
> for children in subsets(free):
> - ntree = dict(tree, **{child: to_expand[0] for child in children})
> + ntree = {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/
--
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20141031/bb8e1c9b/attachment.pgp>
More information about the notmuch
mailing list