Mercurial > hg > mercurial-source
changeset 30810:0f6d6fdd3c2a
pycompat: provide 'ispy3' constant
We compare version_info at several places, which seems enough to define
a constant.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 28 Sep 2016 20:01:23 +0900 |
parents | 3741a8f86e88 |
children | 2219f4f82ede |
files | mercurial/bundle2.py mercurial/encoding.py mercurial/pycompat.py mercurial/util.py |
diffstat | 4 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -159,6 +159,7 @@ error, obsolete, pushkey, + pycompat, tags, url, util, @@ -996,7 +997,7 @@ outdebug(ui, 'closing payload chunk') # abort current part payload yield _pack(_fpayloadsize, 0) - if sys.version_info[0] >= 3: + if pycompat.ispy3: raise exc_info[0](exc_info[1]).with_traceback(exc_info[2]) else: exec("""raise exc_info[0], exc_info[1], exc_info[2]""")
--- a/mercurial/encoding.py +++ b/mercurial/encoding.py @@ -10,14 +10,14 @@ import array import locale import os -import sys import unicodedata from . import ( error, + pycompat, ) -if sys.version_info[0] >= 3: +if pycompat.ispy3: unichr = chr # These unicode characters are ignored by HFS+ (Apple Technote 1150, @@ -27,7 +27,7 @@ "200c 200d 200e 200f 202a 202b 202c 202d 202e " "206a 206b 206c 206d 206e 206f feff".split()] # verify the next function will work -if sys.version_info[0] >= 3: +if pycompat.ispy3: assert set(i[0] for i in _ignore) == set([ord(b'\xe2'), ord(b'\xef')]) else: assert set(i[0] for i in _ignore) == set(["\xe2", "\xef"])
--- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -12,7 +12,9 @@ import sys -if sys.version_info[0] < 3: +ispy3 = (sys.version_info[0] >= 3) + +if not ispy3: import cPickle as pickle import cStringIO as io import httplib @@ -29,7 +31,7 @@ import urllib.parse as urlparse import xmlrpc.client as xmlrpclib -if sys.version_info[0] >= 3: +if ispy3: import builtins import functools @@ -72,7 +74,7 @@ httpserver = _pycompatstub() urlreq = _pycompatstub() urlerr = _pycompatstub() -if sys.version_info[0] < 3: +if not ispy3: import BaseHTTPServer import CGIHTTPServer import SimpleHTTPServer