Patchwork [2,of,4,RFC] pycompat: move xrange alias next to import lines

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 14, 2016, 9:33 a.m.
Message ID <76c2c6169dccde84f84a.1471167226@mimosa>
Download mbox | patch
Permalink /patch/16277/
State Changes Requested
Headers show

Comments

Yuya Nishihara - Aug. 14, 2016, 9:33 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471146114 -32400
#      Sun Aug 14 12:41:54 2016 +0900
# Node ID 76c2c6169dccde84f84a46b7f366020bc3e72959
# Parent  131cc484d7fe95d07f677c16dbb0f506847e1d38
pycompat: 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