comparison mercurial/pycompat.py @ 30030: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 c63ab0524db7
children 2219f4f82ede
comparison
equal deleted inserted replaced
30028:3741a8f86e88 30030:0f6d6fdd3c2a
10 10
11 from __future__ import absolute_import 11 from __future__ import absolute_import
12 12
13 import sys 13 import sys
14 14
15 if sys.version_info[0] < 3: 15 ispy3 = (sys.version_info[0] >= 3)
16
17 if not ispy3:
16 import cPickle as pickle 18 import cPickle as pickle
17 import cStringIO as io 19 import cStringIO as io
18 import httplib 20 import httplib
19 import Queue as _queue 21 import Queue as _queue
20 import SocketServer as socketserver 22 import SocketServer as socketserver
27 import queue as _queue 29 import queue as _queue
28 import socketserver 30 import socketserver
29 import urllib.parse as urlparse 31 import urllib.parse as urlparse
30 import xmlrpc.client as xmlrpclib 32 import xmlrpc.client as xmlrpclib
31 33
32 if sys.version_info[0] >= 3: 34 if ispy3:
33 import builtins 35 import builtins
34 import functools 36 import functools
35 37
36 def _wrapattrfunc(f): 38 def _wrapattrfunc(f):
37 @functools.wraps(f) 39 @functools.wraps(f)
70 return obj 72 return obj
71 73
72 httpserver = _pycompatstub() 74 httpserver = _pycompatstub()
73 urlreq = _pycompatstub() 75 urlreq = _pycompatstub()
74 urlerr = _pycompatstub() 76 urlerr = _pycompatstub()
75 if sys.version_info[0] < 3: 77 if not ispy3:
76 import BaseHTTPServer 78 import BaseHTTPServer
77 import CGIHTTPServer 79 import CGIHTTPServer
78 import SimpleHTTPServer 80 import SimpleHTTPServer
79 import urllib2 81 import urllib2
80 import urllib 82 import urllib