changeset 152:0808bb03add5

util: don't try to use itertools.izip under Python 3 (issue4520) In Python 3, itertools.izip became builtins.zip.
author Brett Cannon <brett@python.org>
date Fri, 20 Mar 2015 16:32:53 -0400
parents b91356bf7186
children ef8eb78fc88d
files hglib/util.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hglib/util.py	Thu Mar 19 17:42:46 2015 -0400
+++ b/hglib/util.py	Fri Mar 20 16:32:53 2015 -0400
@@ -1,4 +1,4 @@
-import itertools, os, subprocess, sys
+import os, subprocess, sys
 from hglib import error
 try:
     from io import BytesIO
@@ -6,10 +6,14 @@
     from cStringIO import StringIO as BytesIO
 
 if sys.version_info[0] > 2:
+    izip = zip
+
     def b(s):
         """Encode the string as bytes."""
         return s.encode('latin-1')
 else:
+    from itertools import izip
+
     def b(s):
         """Encode the string as bytes."""
         return s
@@ -21,7 +25,7 @@
 def grouper(n, iterable):
     ''' list(grouper(2, range(4))) -> [(0, 1), (2, 3)] '''
     args = [iter(iterable)] * n
-    return itertools.izip(*args)
+    return izip(*args)
 
 def eatlines(s, n):
     """