Show More
@@ -49,7 +49,7 b' if ispy3:' | |||
|
49 | 49 | def sysstr(s): |
|
50 | 50 | if isinstance(s, builtins.str): |
|
51 | 51 | return s |
|
52 |
return s.decode( |
|
|
52 | return s.decode('latin-1') | |
|
53 | 53 | |
|
54 | 54 | def opentext(f): |
|
55 | 55 | return open(f, 'r') |
@@ -394,7 +394,7 b' class _gitlfsremote(object):' | |||
|
394 | 394 | |
|
395 | 395 | def encodestr(x): |
|
396 | 396 | if isinstance(x, pycompat.unicode): |
|
397 |
return x.encode( |
|
|
397 | return x.encode('utf-8') | |
|
398 | 398 | return x |
|
399 | 399 | |
|
400 | 400 | return pycompat.rapply(encodestr, response) |
@@ -166,14 +166,6 b' if sys.version_info[0] >= 3:' | |||
|
166 | 166 | if arg1idx is not None: |
|
167 | 167 | _ensureunicode(arg1idx) |
|
168 | 168 | |
|
169 | # .encode() and .decode() on str/bytes/unicode don't accept | |
|
170 | # byte strings on Python 3. | |
|
171 | elif fn in ('encode', 'decode') and _isop(i - 1, '.'): | |
|
172 | for argn in range(2): | |
|
173 | argidx = _findargnofcall(argn) | |
|
174 | if argidx is not None: | |
|
175 | _ensureunicode(argidx) | |
|
176 | ||
|
177 | 169 | # It changes iteritems/values to items/values as they are not |
|
178 | 170 | # present in Python 3 world. |
|
179 | 171 | elif fn in ('iteritems', 'itervalues') and not ( |
@@ -190,7 +182,7 b' if sys.version_info[0] >= 3:' | |||
|
190 | 182 | # ``replacetoken`` or any mechanism that changes semantics of module |
|
191 | 183 | # loading is changed. Otherwise cached bytecode may get loaded without |
|
192 | 184 | # the new transformation mechanisms applied. |
|
193 |
BYTECODEHEADER = b'HG\x00\x1 |
|
|
185 | BYTECODEHEADER = b'HG\x00\x13' | |
|
194 | 186 | |
|
195 | 187 | class hgloader(importlib.machinery.SourceFileLoader): |
|
196 | 188 | """Custom module loader that transforms source code. |
@@ -206,7 +206,7 b' if ispy3:' | |||
|
206 | 206 | ) and not hasattr( # hasattr-py3-only |
|
207 | 207 | s, u'__bytes__' |
|
208 | 208 | ): |
|
209 |
s = str(s).encode( |
|
|
209 | s = str(s).encode('ascii') | |
|
210 | 210 | return bytes.__new__(cls, s) |
|
211 | 211 | |
|
212 | 212 | def __getitem__(self, key): |
@@ -237,7 +237,7 b' if ispy3:' | |||
|
237 | 237 | This never raises UnicodeEncodeError, but only ASCII characters |
|
238 | 238 | can be round-trip by sysstr(sysbytes(s)). |
|
239 | 239 | """ |
|
240 |
return s.encode( |
|
|
240 | return s.encode('utf-8') | |
|
241 | 241 | |
|
242 | 242 | def sysstr(s): |
|
243 | 243 | """Return a keyword str to be passed to Python functions such as |
@@ -249,18 +249,18 b' if ispy3:' | |||
|
249 | 249 | """ |
|
250 | 250 | if isinstance(s, builtins.str): |
|
251 | 251 | return s |
|
252 |
return s.decode( |
|
|
252 | return s.decode('latin-1') | |
|
253 | 253 | |
|
254 | 254 | def strurl(url): |
|
255 | 255 | """Converts a bytes url back to str""" |
|
256 | 256 | if isinstance(url, bytes): |
|
257 |
return url.decode( |
|
|
257 | return url.decode('ascii') | |
|
258 | 258 | return url |
|
259 | 259 | |
|
260 | 260 | def bytesurl(url): |
|
261 | 261 | """Converts a str url to bytes by encoding in ascii""" |
|
262 | 262 | if isinstance(url, str): |
|
263 |
return url.encode( |
|
|
263 | return url.encode('ascii') | |
|
264 | 264 | return url |
|
265 | 265 | |
|
266 | 266 | def raisewithtb(exc, tb): |
General Comments 0
You need to be logged in to leave comments.
Login now