pycompat: add xrange alias for Python 2
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 01 Aug 2018 12:57:15 -0700
changeset 47111 7eba8f83129bc0642d19ee72ae335d0d1846803e
parent 47110 0a57945aaf7f80438086e1c414ff3b9ec06266d8
child 47112 e7aa113b14f77959ad4039d873b57100a4d56b31
push id837
push usergszorc@mozilla.com
push dateFri, 03 Aug 2018 01:30:56 +0000
pycompat: add xrange alias for Python 2 We assign xrange on Python 3 but not Python 2. Adding the missing symbol on Python 2 allows us to use `pycompat.xrange` to get a generator range function. Differential Revision: https://phab.mercurial-scm.org/D4031
mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -326,16 +326,17 @@ if ispy3:
         Python 3 compatibility as shelx.split() don't accept bytes on Python 3.
         """
         ret = shlex.split(s.decode('latin-1'), comments, posix)
         return [a.encode('latin-1') for a in ret]
 
 else:
     import cStringIO
 
+    xrange = xrange
     unicode = unicode
     bytechr = chr
     byterepr = repr
     bytestr = str
     iterbytestr = iter
     maybebytestr = identity
     sysbytes = identity
     sysstr = identity