Mercurial > public > mercurial-scm > hg-stable
diff mercurial/pycompat.py @ 29811:178c89e8519a
py3: import builtin wrappers automagically by code transformer
This should be less invasive than mucking builtins.
Since tokenize.untokenize() looks start/end positions of tokens, we calculates
them from the NEWLINE token of the future import.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 16 Aug 2016 12:35:15 +0900 |
parents | 45fa8de47a0f |
children | c63ab0524db7 |
line wrap: on
line diff
--- a/mercurial/pycompat.py Sun Aug 14 12:51:21 2016 +0900 +++ b/mercurial/pycompat.py Tue Aug 16 12:35:15 2016 +0900 @@ -32,7 +32,6 @@ if sys.version_info[0] >= 3: import builtins import functools - builtins.xrange = range def _wrapattrfunc(f): @functools.wraps(f) @@ -42,10 +41,12 @@ return f(object, name, *args) return w + # these wrappers are automagically imported by hgloader delattr = _wrapattrfunc(builtins.delattr) getattr = _wrapattrfunc(builtins.getattr) hasattr = _wrapattrfunc(builtins.hasattr) setattr = _wrapattrfunc(builtins.setattr) + xrange = builtins.range stringio = io.StringIO empty = _queue.Empty