Patchwork [3,of,4,RFC] pycompat: check python version to enable builtins hack

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 14, 2016, 9:33 a.m.
Message ID <d53bd633898ec6edafcc.1471167227@mimosa>
Download mbox | patch
Permalink /patch/16278/
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 1471146253 -32400
#      Sun Aug 14 12:44:13 2016 +0900
# Node ID d53bd633898ec6edafccea9f798d314699faf90a
# Parent  76c2c6169dccde84f84a46b7f366020bc3e72959
pycompat: check python version to enable builtins hack

Future patches will add getattr/setattr wrappers.

Patch

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -29,9 +29,7 @@  else:
     import urllib.parse as urlparse
     import xmlrpc.client as xmlrpclib
 
-try:
-    xrange
-except NameError:
+if sys.version_info[0] >= 3:
     import builtins
     builtins.xrange = range