Show More
@@ -246,7 +246,7 b' class converter_source(object):' | |||
|
246 | 246 | if not encoding: |
|
247 | 247 | encoding = self.encoding or b'utf-8' |
|
248 | 248 | |
|
249 |
if isinstance(s, |
|
|
249 | if isinstance(s, str): | |
|
250 | 250 | return s.encode("utf-8") |
|
251 | 251 | try: |
|
252 | 252 | return s.decode(pycompat.sysstr(encoding)).encode("utf-8") |
@@ -86,7 +86,7 b' def readauthormap(ui, authorfile, author' | |||
|
86 | 86 | |
|
87 | 87 | |
|
88 | 88 | def recode(s): |
|
89 |
if isinstance(s, |
|
|
89 | if isinstance(s, str): | |
|
90 | 90 | return s.encode(pycompat.sysstr(orig_encoding), 'replace') |
|
91 | 91 | else: |
|
92 | 92 | return s.decode('utf-8').encode( |
@@ -113,7 +113,7 b' class darcs_source(common.converter_sour' | |||
|
113 | 113 | shutil.rmtree(self.tmppath, ignore_errors=True) |
|
114 | 114 | |
|
115 | 115 | def recode(self, s, encoding=None): |
|
116 |
if isinstance(s, |
|
|
116 | if isinstance(s, str): | |
|
117 | 117 | # XMLParser returns unicode objects for anything it can't |
|
118 | 118 | # encode into ASCII. We convert them back to str to get |
|
119 | 119 | # recode's normal conversion behavior. |
@@ -273,7 +273,7 b' def _urlerrorreason(urlerror):' | |||
|
273 | 273 | except (AttributeError, IndexError): |
|
274 | 274 | # it might be anything, for example a string |
|
275 | 275 | reason = inst.reason |
|
276 |
if isinstance(reason, |
|
|
276 | if isinstance(reason, str): | |
|
277 | 277 | # SSLError of Python 2.7.9 contains a unicode |
|
278 | 278 | reason = encoding.unitolocal(reason) |
|
279 | 279 | return reason |
@@ -406,7 +406,7 b' class _gitlfsremote(object):' | |||
|
406 | 406 | ) |
|
407 | 407 | |
|
408 | 408 | def encodestr(x): |
|
409 |
if isinstance(x, |
|
|
409 | if isinstance(x, str): | |
|
410 | 410 | return x.encode('utf-8') |
|
411 | 411 | return x |
|
412 | 412 |
@@ -219,9 +219,7 b' def _loadhgrc(orig, ui, wdirvfs, hgvfs, ' | |||
|
219 | 219 | rawparams = encoding.unifromlocal(wdirvfs.read(b".arcconfig")) |
|
220 | 220 | # json.loads only returns unicode strings |
|
221 | 221 | arcconfig = pycompat.rapply( |
|
222 | lambda x: encoding.unitolocal(x) | |
|
223 | if isinstance(x, pycompat.unicode) | |
|
224 | else x, | |
|
222 | lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, | |
|
225 | 223 | pycompat.json_loads(rawparams), |
|
226 | 224 | ) |
|
227 | 225 | |
@@ -447,9 +445,7 b' def callconduit(ui, name, params):' | |||
|
447 | 445 | time.sleep(retry_interval) |
|
448 | 446 | ui.debug(b'Conduit Response: %s\n' % body) |
|
449 | 447 | parsed = pycompat.rapply( |
|
450 | lambda x: encoding.unitolocal(x) | |
|
451 | if isinstance(x, pycompat.unicode) | |
|
452 | else x, | |
|
448 | lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, | |
|
453 | 449 | # json.loads only accepts bytes from py3.6+ |
|
454 | 450 | pycompat.json_loads(encoding.unifromlocal(body)), |
|
455 | 451 | ) |
@@ -473,9 +469,7 b' def debugcallconduit(ui, repo, name):' | |||
|
473 | 469 | rawparams = encoding.unifromlocal(ui.fin.read()) |
|
474 | 470 | # json.loads only returns unicode strings |
|
475 | 471 | params = pycompat.rapply( |
|
476 | lambda x: encoding.unitolocal(x) | |
|
477 | if isinstance(x, pycompat.unicode) | |
|
478 | else x, | |
|
472 | lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, | |
|
479 | 473 | pycompat.json_loads(rawparams), |
|
480 | 474 | ) |
|
481 | 475 | # json.dumps only accepts unicode strings |
@@ -94,7 +94,7 b' def decode(arg):' | |||
|
94 | 94 | |
|
95 | 95 | |
|
96 | 96 | def encode(arg): |
|
97 |
if isinstance(arg, |
|
|
97 | if isinstance(arg, str): | |
|
98 | 98 | return arg.encode(_encoding) |
|
99 | 99 | elif isinstance(arg, tuple): |
|
100 | 100 | return tuple(map(encode, arg)) |
@@ -135,7 +135,7 b' def basewrapper(func, argtype, enc, dec,' | |||
|
135 | 135 | |
|
136 | 136 | |
|
137 | 137 | def wrapper(func, args, kwds): |
|
138 |
return basewrapper(func, |
|
|
138 | return basewrapper(func, str, encode, decode, args, kwds) | |
|
139 | 139 | |
|
140 | 140 | |
|
141 | 141 | def reversewrapper(func, args, kwds): |
@@ -36,7 +36,7 b' def hgweb(config, name=None, baseui=None' | |||
|
36 | 36 | - list of virtual:real tuples (multi-repo view) |
|
37 | 37 | """ |
|
38 | 38 | |
|
39 |
if isinstance(config, |
|
|
39 | if isinstance(config, str): | |
|
40 | 40 | raise error.ProgrammingError( |
|
41 | 41 | b'Mercurial only supports encoded strings: %r' % config |
|
42 | 42 | ) |
@@ -85,9 +85,9 b' def gettext(message):' | |||
|
85 | 85 | |
|
86 | 86 | cache = _msgcache.setdefault(encoding.encoding, {}) |
|
87 | 87 | if message not in cache: |
|
88 |
if type(message) is |
|
|
88 | if type(message) is str: | |
|
89 | 89 | # goofy unicode docstrings in test |
|
90 |
paragraphs = message.split(u'\n\n') # type: List[ |
|
|
90 | paragraphs = message.split(u'\n\n') # type: List[str] | |
|
91 | 91 | else: |
|
92 | 92 | # should be ascii, but we have unicode docstrings in test, which |
|
93 | 93 | # are converted to utf-8 bytes on Python 3. |
@@ -227,7 +227,7 b' def callcatch(ui, func):' | |||
|
227 | 227 | except (AttributeError, IndexError): |
|
228 | 228 | # it might be anything, for example a string |
|
229 | 229 | reason = inst.reason |
|
230 |
if isinstance(reason, |
|
|
230 | if isinstance(reason, str): | |
|
231 | 231 | # SSLError of Python 2.7.9 contains a unicode |
|
232 | 232 | reason = encoding.unitolocal(reason) |
|
233 | 233 | ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason)) |
@@ -372,9 +372,7 b' def obfuscate(text):' | |||
|
372 | 372 | """Any text. Returns the input text rendered as a sequence of |
|
373 | 373 | XML entities. |
|
374 | 374 | """ |
|
375 | text = pycompat.unicode( | |
|
376 | text, pycompat.sysstr(encoding.encoding), r'replace' | |
|
377 | ) | |
|
375 | text = str(text, pycompat.sysstr(encoding.encoding), r'replace') | |
|
378 | 376 | return b''.join([b'&#%d;' % ord(c) for c in text]) |
|
379 | 377 | |
|
380 | 378 |
General Comments 0
You need to be logged in to leave comments.
Login now