##// END OF EJS Templates
pycompat: provide 'ispy3' constant...
Yuya Nishihara -
r30030:0f6d6fdd default
parent child Browse files
Show More
@@ -159,6 +159,7 b' from . import ('
159 error,
159 error,
160 obsolete,
160 obsolete,
161 pushkey,
161 pushkey,
162 pycompat,
162 tags,
163 tags,
163 url,
164 url,
164 util,
165 util,
@@ -996,7 +997,7 b' class bundlepart(object):'
996 outdebug(ui, 'closing payload chunk')
997 outdebug(ui, 'closing payload chunk')
997 # abort current part payload
998 # abort current part payload
998 yield _pack(_fpayloadsize, 0)
999 yield _pack(_fpayloadsize, 0)
999 if sys.version_info[0] >= 3:
1000 if pycompat.ispy3:
1000 raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
1001 raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
1001 else:
1002 else:
1002 exec("""raise exc_info[0], exc_info[1], exc_info[2]""")
1003 exec("""raise exc_info[0], exc_info[1], exc_info[2]""")
@@ -10,14 +10,14 b' from __future__ import absolute_import'
10 import array
10 import array
11 import locale
11 import locale
12 import os
12 import os
13 import sys
14 import unicodedata
13 import unicodedata
15
14
16 from . import (
15 from . import (
17 error,
16 error,
17 pycompat,
18 )
18 )
19
19
20 if sys.version_info[0] >= 3:
20 if pycompat.ispy3:
21 unichr = chr
21 unichr = chr
22
22
23 # These unicode characters are ignored by HFS+ (Apple Technote 1150,
23 # These unicode characters are ignored by HFS+ (Apple Technote 1150,
@@ -27,7 +27,7 b' if sys.version_info[0] >= 3:'
27 "200c 200d 200e 200f 202a 202b 202c 202d 202e "
27 "200c 200d 200e 200f 202a 202b 202c 202d 202e "
28 "206a 206b 206c 206d 206e 206f feff".split()]
28 "206a 206b 206c 206d 206e 206f feff".split()]
29 # verify the next function will work
29 # verify the next function will work
30 if sys.version_info[0] >= 3:
30 if pycompat.ispy3:
31 assert set(i[0] for i in _ignore) == set([ord(b'\xe2'), ord(b'\xef')])
31 assert set(i[0] for i in _ignore) == set([ord(b'\xe2'), ord(b'\xef')])
32 else:
32 else:
33 assert set(i[0] for i in _ignore) == set(["\xe2", "\xef"])
33 assert set(i[0] for i in _ignore) == set(["\xe2", "\xef"])
@@ -12,7 +12,9 b' 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
@@ -29,7 +31,7 b' else:'
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
@@ -72,7 +74,7 b' class _pycompatstub(object):'
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
@@ -232,7 +232,7 b' class digestchecker(object):'
232 try:
232 try:
233 buffer = buffer
233 buffer = buffer
234 except NameError:
234 except NameError:
235 if sys.version_info[0] < 3:
235 if not pycompat.ispy3:
236 def buffer(sliceable, offset=0):
236 def buffer(sliceable, offset=0):
237 return sliceable[offset:]
237 return sliceable[offset:]
238 else:
238 else:
General Comments 0
You need to be logged in to leave comments. Login now