[PATCH 1 of 2 hglib] util: don't try to use itertools.izip under Python 3 (issue4520)
Brett Cannon
brett at python.org
Fri Mar 20 20:35:01 UTC 2015
# HG changeset patch
# User Brett Cannon <brett at python.org>
# Date 1426883573 14400
# Fri Mar 20 16:32:53 2015 -0400
# Node ID 0808bb03add5fe4f264ac90926f64b3ca6b75730
# Parent b91356bf7186845d21a219fa5282f1fa9dade69c
util: don't try to use itertools.izip under Python 3 (issue4520)
In Python 3, itertools.izip became builtins.zip.
diff -r b91356bf7186 -r 0808bb03add5 hglib/util.py
--- 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):
"""
More information about the Mercurial-devel
mailing list