Patchwork [2,of,5,V2] py3: move xrange alias next to import lines

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 16, 2016, 8:50 a.m.
Message ID <72d31f469f3b89eddd3f.1471337443@mimosa>
Download mbox | patch
Permalink /patch/16319/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 16, 2016, 8:50 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471146114 -32400
#      Sun Aug 14 12:41:54 2016 +0900
# Node ID 72d31f469f3b89eddd3f138af567bed3a9fac0a7
# Parent  2a4b9fa66b0b568c50e2069b44cf01ea79eba6df
py3: move xrange alias next to import lines

Builtin functions should be available in compatibility code.

Patch

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -29,6 +29,12 @@  else:
     import urllib.parse as urlparse
     import xmlrpc.client as xmlrpclib
 
+try:
+    xrange
+except NameError:
+    import builtins
+    builtins.xrange = range
+
 stringio = io.StringIO
 empty = _queue.Empty
 queue = _queue.Queue
@@ -145,9 +151,3 @@  else:
         "SimpleHTTPRequestHandler",
         "CGIHTTPRequestHandler",
     ))
-
-try:
-    xrange
-except NameError:
-    import builtins
-    builtins.xrange = range