##// END OF EJS Templates
py3: factor out bytechr() function...
Yuya Nishihara -
r31253:64596338 default
parent child Browse files
Show More
@@ -71,6 +71,9 b' if ispy3:'
71 71 # workaround to simulate the Python 2 (i.e. ANSI Win32 API) behavior.
72 72 sysargv = list(map(os.fsencode, sys.argv))
73 73
74 def bytechr(i):
75 return bytes([i])
76
74 77 def sysstr(s):
75 78 """Return a keyword str to be passed to Python functions such as
76 79 getattr() and str.encode()
@@ -134,6 +137,8 b' if ispy3:'
134 137 return [a.encode('latin-1') for a in ret]
135 138
136 139 else:
140 bytechr = chr
141
137 142 def sysstr(s):
138 143 return s
139 144
@@ -99,12 +99,8 b' def _buildencodefun():'
99 99 'the\\x07quick\\xadshot'
100 100 '''
101 101 e = '_'
102 if pycompat.ispy3:
103 xchr = lambda x: bytes([x])
104 asciistr = [bytes([a]) for a in range(127)]
105 else:
106 xchr = chr
107 asciistr = map(chr, xrange(127))
102 xchr = pycompat.bytechr
103 asciistr = list(map(xchr, range(127)))
108 104 capitals = list(range(ord("A"), ord("Z") + 1))
109 105
110 106 cmap = dict((x, x) for x in asciistr)
@@ -40,12 +40,8 b' from . import ('
40 40 urlreq = util.urlreq
41 41
42 42 # for use with str.translate(None, _keepalnum), to keep just alphanumerics
43 if pycompat.ispy3:
44 _bytes = [bytes([c]) for c in range(256)]
45 _notalnum = [s for s in _bytes if not s.isalnum()]
46 else:
47 _notalnum = [c for c in map(chr, range(256)) if not c.isalnum()]
48 _keepalnum = ''.join(_notalnum)
43 _keepalnum = ''.join(c for c in map(pycompat.bytechr, range(256))
44 if not c.isalnum())
49 45
50 46 samplehgrcs = {
51 47 'user':
General Comments 0
You need to be logged in to leave comments. Login now