[PATCH] test: Make gen-threads work with python3

2014-11-02 Thread David Bremner
Jesse Rosenthal  writes:

> python3 doesn't allow dictionaries to be initialized with non-string
> keywords. This presents problems on systems in which "python" means
> "python3". 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.

pushed.

d


Re: [PATCH] test: Make gen-threads work with python3

2014-11-02 Thread David Bremner
Jesse Rosenthal  writes:

> python3 doesn't allow dictionaries to be initialized with non-string
> keywords. This presents problems on systems in which "python" means
> "python3". 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.

pushed.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: Make gen-threads work with python3

2014-11-01 Thread Tomi Ollila
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 ?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 ;).

Thanks Trevor. The original changed line:

-  ntree = dict(tree, **{child: to_expand[0] for child in children})

is already incompatible with python 2.6, so this doesn't change the current 
status quo there.

The above changed to 

+  ntree = 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
>>  
>> @@ -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
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: Make gen-threads work with python3

2014-11-01 Thread Tomi Ollila
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 ‘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 ;).

Thanks Trevor. The original changed line:

-  ntree = dict(tree, **{child: to_expand[0] for child in children})

is already incompatible with python 2.6, so this doesn't change the current 
status quo there.

The above changed to 

+  ntree = 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
>>  
>> @@ -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
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: Make gen-threads work with python3

2014-10-31 Thread Jesse Rosenthal
"W. Trevor King"  writes:

> 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 ;).

The comprehension was already in the previous version, so I figured that
people were already cool with 2.7+.

>> -
>>  import sys
>
> Why remove this blank line?

Oops -- I had put in a print_function import from __future__ for
testing. Must have lost the line when I took it back out. Is it worth
resubmitting to fix that?


[PATCH] test: Make gen-threads work with python3

2014-10-31 Thread Jesse Rosenthal
python3 doesn't allow dictionaries to be initialized with non-string
keywords. This presents problems on systems in which "python" means
"python3". 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.
---
 test/gen-threads.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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
 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)
 nfree = free.difference(children)
 queue.append((ntree, nfree, to_expand[1:] + tuple(children)))
-- 
2.1.2



Re: [PATCH] test: Make gen-threads work with python3

2014-10-31 Thread Jesse Rosenthal
"W. Trevor King"  writes:

> 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 ;).

The comprehension was already in the previous version, so I figured that
people were already cool with 2.7+.

>> -
>>  import sys
>
> Why remove this blank line?

Oops -- I had put in a print_function import from __future__ for
testing. Must have lost the line when I took it back out. Is it worth
resubmitting to fix that?
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: Make gen-threads work with python3

2014-10-31 Thread W. Trevor King
On Fri, Oct 31, 2014 at 02:04:50PM -0400, Jesse Rosenthal wrote:
> W. Trevor King writes:
> > 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 ;).
> 
> The comprehension was already in the previous version, so I figured that
> people were already cool with 2.7+.

Ah, good point :).  Besides looking good to me, I can confirm that I
see a TypeError (and a lot of CPU usage ;) from T260-thread-order.sh
before this patch which is fixed by this patch.

Cheers,
Trevor

-- 
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


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: Make gen-threads work with python3

2014-10-31 Thread W. Trevor King
On Fri, Oct 31, 2014 at 02:04:50PM -0400, Jesse Rosenthal wrote:
> W. Trevor King writes:
> > 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 ;).
> 
> The comprehension was already in the previous version, so I figured that
> people were already cool with 2.7+.

Ah, good point :).  Besides looking good to me, I can confirm that I
see a TypeError (and a lot of CPU usage ;) from T260-thread-order.sh
before this patch which is fixed by this patch.

Cheers,
Trevor

-- 
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: 



Re: [PATCH] test: Make gen-threads work with python3

2014-10-31 Thread W. Trevor King
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


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: Make gen-threads work with python3

2014-10-31 Thread W. Trevor King
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: 



[PATCH] test: Make gen-threads work with python3

2014-10-31 Thread Jesse Rosenthal
python3 doesn't allow dictionaries to be initialized with non-string
keywords. This presents problems on systems in which "python" means
"python3". 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.
---
 test/gen-threads.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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
 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)
 nfree = free.difference(children)
 queue.append((ntree, nfree, to_expand[1:] + tuple(children)))
-- 
2.1.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch