Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 44470:9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Built with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**' | xargs pyupgrade --keep-percent-format --keep-extraneous-parens
and then blackened. pyupgrade comes from
https://github.com/asottile/pyupgrade with a patch to let me preserve
extraneous parens (which we use for marking strings that shouldn't be
translated), and lets us clean up a bunch of idioms that have cruftily
accumulated over the years.
# skip-blame no-op automated code cleanups
Differential Revision: https://phab.mercurial-scm.org/D8255
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 06 Mar 2020 13:27:41 -0500 |
parents | be8552f25cab |
children | a736ab681b78 |
comparison
equal
deleted
inserted
replaced
44469:ff72bd52d56a | 44470:9d2b2df2c2ba |
---|---|
84 elif _nativeenviron: | 84 elif _nativeenviron: |
85 environ = os.environb # re-exports | 85 environ = os.environb # re-exports |
86 else: | 86 else: |
87 # preferred encoding isn't known yet; use utf-8 to avoid unicode error | 87 # preferred encoding isn't known yet; use utf-8 to avoid unicode error |
88 # and recreate it once encoding is settled | 88 # and recreate it once encoding is settled |
89 environ = dict( | 89 environ = { |
90 (k.encode('utf-8'), v.encode('utf-8')) | 90 k.encode('utf-8'): v.encode('utf-8') |
91 for k, v in os.environ.items() # re-exports | 91 for k, v in os.environ.items() # re-exports |
92 ) | 92 } |
93 | 93 |
94 _encodingrewrites = { | 94 _encodingrewrites = { |
95 b'646': b'ascii', | 95 b'646': b'ascii', |
96 b'ANSI_X3.4-1968': b'ascii', | 96 b'ANSI_X3.4-1968': b'ascii', |
97 } | 97 } |
283 strmethod = pycompat.identity | 283 strmethod = pycompat.identity |
284 | 284 |
285 if not _nativeenviron: | 285 if not _nativeenviron: |
286 # now encoding and helper functions are available, recreate the environ | 286 # now encoding and helper functions are available, recreate the environ |
287 # dict to be exported to other modules | 287 # dict to be exported to other modules |
288 environ = dict( | 288 environ = { |
289 (tolocal(k.encode('utf-8')), tolocal(v.encode('utf-8'))) | 289 tolocal(k.encode('utf-8')): tolocal(v.encode('utf-8')) |
290 for k, v in os.environ.items() # re-exports | 290 for k, v in os.environ.items() # re-exports |
291 ) | 291 } |
292 | 292 |
293 if pycompat.ispy3: | 293 if pycompat.ispy3: |
294 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which | 294 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which |
295 # returns bytes. | 295 # returns bytes. |
296 if pycompat.iswindows: | 296 if pycompat.iswindows: |