Mercurial > public > mercurial-scm > hg
comparison hgext/phabricator.py @ 48934:06de08b36c82
py3: use str instead of pycompat.unicode
pycompat.unicode is an alias to str.
Differential Revision: https://phab.mercurial-scm.org/D12340
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 21 Feb 2022 11:24:57 -0700 |
parents | f254fc73d956 |
children | 642e31cb55f0 |
comparison
equal
deleted
inserted
replaced
48933:78f1de3f4be7 | 48934:06de08b36c82 |
---|---|
217 try: | 217 try: |
218 # json.loads only accepts bytes from 3.6+ | 218 # json.loads only accepts bytes from 3.6+ |
219 rawparams = encoding.unifromlocal(wdirvfs.read(b".arcconfig")) | 219 rawparams = encoding.unifromlocal(wdirvfs.read(b".arcconfig")) |
220 # json.loads only returns unicode strings | 220 # json.loads only returns unicode strings |
221 arcconfig = pycompat.rapply( | 221 arcconfig = pycompat.rapply( |
222 lambda x: encoding.unitolocal(x) | 222 lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, |
223 if isinstance(x, pycompat.unicode) | |
224 else x, | |
225 pycompat.json_loads(rawparams), | 223 pycompat.json_loads(rawparams), |
226 ) | 224 ) |
227 | 225 |
228 result = True | 226 result = True |
229 except ValueError: | 227 except ValueError: |
445 # failing request might come from overloaded server | 443 # failing request might come from overloaded server |
446 retry_interval = ui.configint(b'phabricator', b'retry.interval') | 444 retry_interval = ui.configint(b'phabricator', b'retry.interval') |
447 time.sleep(retry_interval) | 445 time.sleep(retry_interval) |
448 ui.debug(b'Conduit Response: %s\n' % body) | 446 ui.debug(b'Conduit Response: %s\n' % body) |
449 parsed = pycompat.rapply( | 447 parsed = pycompat.rapply( |
450 lambda x: encoding.unitolocal(x) | 448 lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, |
451 if isinstance(x, pycompat.unicode) | |
452 else x, | |
453 # json.loads only accepts bytes from py3.6+ | 449 # json.loads only accepts bytes from py3.6+ |
454 pycompat.json_loads(encoding.unifromlocal(body)), | 450 pycompat.json_loads(encoding.unifromlocal(body)), |
455 ) | 451 ) |
456 if parsed.get(b'error_code'): | 452 if parsed.get(b'error_code'): |
457 msg = _(b'Conduit Error (%s): %s') % ( | 453 msg = _(b'Conduit Error (%s): %s') % ( |
471 """ | 467 """ |
472 # json.loads only accepts bytes from 3.6+ | 468 # json.loads only accepts bytes from 3.6+ |
473 rawparams = encoding.unifromlocal(ui.fin.read()) | 469 rawparams = encoding.unifromlocal(ui.fin.read()) |
474 # json.loads only returns unicode strings | 470 # json.loads only returns unicode strings |
475 params = pycompat.rapply( | 471 params = pycompat.rapply( |
476 lambda x: encoding.unitolocal(x) | 472 lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, |
477 if isinstance(x, pycompat.unicode) | |
478 else x, | |
479 pycompat.json_loads(rawparams), | 473 pycompat.json_loads(rawparams), |
480 ) | 474 ) |
481 # json.dumps only accepts unicode strings | 475 # json.dumps only accepts unicode strings |
482 result = pycompat.rapply( | 476 result = pycompat.rapply( |
483 lambda x: encoding.unifromlocal(x) if isinstance(x, bytes) else x, | 477 lambda x: encoding.unifromlocal(x) if isinstance(x, bytes) else x, |