comparison mercurial/encoding.py @ 43506:9f70512ae2cf

cleanup: remove pointless r-prefixes on single-quoted strings This is the promised second step on single-quoted strings. These had existed because our source transformer didn't turn r'' into b'', so we had tagged some strings as r-strings to get "native" strings on both Pythons. Now that the transformer is gone, we can dispense with this nonsense. Methodology: I ran hg locate 'set:added() or modified() or clean()' | egrep '.*\.py$' | xargs egrep --color=never -n -- \[\^b\]\[\^a-z\]r\'\[\^\'\\\\\]\*\'\[\^\'\ in an emacs grep-mode buffer, and then used a keyboard macro to iterate over the results and remove the r prefix as needed. # skip-blame removing unneeded r prefixes left over from Python 3 migration. Differential Revision: https://phab.mercurial-scm.org/D7306
author Augie Fackler <augie@google.com>
date Fri, 08 Nov 2019 11:19:20 -0800
parents 313e3a279828
children 7edc07fb890c
comparison
equal deleted inserted replaced
43505:47fac1692ede 43506:9f70512ae2cf
35 for t in (Any, Callable, List, Text, Type, Union): 35 for t in (Any, Callable, List, Text, Type, Union):
36 assert t 36 assert t
37 37
38 _Tlocalstr = TypeVar('_Tlocalstr', bound=localstr) 38 _Tlocalstr = TypeVar('_Tlocalstr', bound=localstr)
39 39
40 charencode = policy.importmod(r'charencode') 40 charencode = policy.importmod('charencode')
41 41
42 isasciistr = charencode.isasciistr 42 isasciistr = charencode.isasciistr
43 asciilower = charencode.asciilower 43 asciilower = charencode.asciilower
44 asciiupper = charencode.asciiupper 44 asciiupper = charencode.asciiupper
45 _jsonescapeu8fast = charencode.jsonescapeu8fast 45 _jsonescapeu8fast = charencode.jsonescapeu8fast
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 = dict(
90 (k.encode(r'utf-8'), v.encode(r'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',
278 278
279 if not _nativeenviron: 279 if not _nativeenviron:
280 # now encoding and helper functions are available, recreate the environ 280 # now encoding and helper functions are available, recreate the environ
281 # dict to be exported to other modules 281 # dict to be exported to other modules
282 environ = dict( 282 environ = dict(
283 (tolocal(k.encode(r'utf-8')), tolocal(v.encode(r'utf-8'))) 283 (tolocal(k.encode('utf-8')), tolocal(v.encode('utf-8')))
284 for k, v in os.environ.items() # re-exports 284 for k, v in os.environ.items() # re-exports
285 ) 285 )
286 286
287 if pycompat.ispy3: 287 if pycompat.ispy3:
288 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which 288 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
305 305
306 306
307 def colwidth(s): 307 def colwidth(s):
308 # type: (bytes) -> int 308 # type: (bytes) -> int
309 b"Find the column width of a string for display in the local encoding" 309 b"Find the column width of a string for display in the local encoding"
310 return ucolwidth(s.decode(_sysstr(encoding), r'replace')) 310 return ucolwidth(s.decode(_sysstr(encoding), 'replace'))
311 311
312 312
313 def ucolwidth(d): 313 def ucolwidth(d):
314 # type: (Text) -> int 314 # type: (Text) -> int
315 b"Find the column width of a Unicode string for display" 315 b"Find the column width of a Unicode string for display"