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