##// END OF EJS Templates
contrib: drop py2 support from testparseutil.py
Matt Harbison -
r50770:cd3b8fd1 default
parent child Browse files
Show More
@@ -7,14 +7,12 b''
7
7
8
8
9 import abc
9 import abc
10 import builtins
10 import re
11 import re
11 import sys
12
12
13 ####################
13 ####################
14 # for Python3 compatibility (almost comes from mercurial/pycompat.py)
14 # for Python3 compatibility (almost comes from mercurial/pycompat.py)
15
15
16 ispy3 = sys.version_info[0] >= 3
17
18
16
19 def identity(a):
17 def identity(a):
20 return a
18 return a
@@ -38,29 +36,21 b' def rapply(f, xs):'
38 return _rapply(f, xs)
36 return _rapply(f, xs)
39
37
40
38
41 if ispy3:
42 import builtins
43
44 def bytestr(s):
39 def bytestr(s):
45 # tiny version of pycompat.bytestr
40 # tiny version of pycompat.bytestr
46 return s.encode('latin1')
41 return s.encode('latin1')
47
42
43
48 def sysstr(s):
44 def sysstr(s):
49 if isinstance(s, builtins.str):
45 if isinstance(s, builtins.str):
50 return s
46 return s
51 return s.decode('latin-1')
47 return s.decode('latin-1')
52
48
49
53 def opentext(f):
50 def opentext(f):
54 return open(f, 'r')
51 return open(f, 'r')
55
52
56
53
57 else:
58 bytestr = str
59 sysstr = identity
60
61 opentext = open
62
63
64 def b2s(x):
54 def b2s(x):
65 # convert BYTES elements in "x" to SYSSTR recursively
55 # convert BYTES elements in "x" to SYSSTR recursively
66 return rapply(sysstr, x)
56 return rapply(sysstr, x)
General Comments 0
You need to be logged in to leave comments. Login now