Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pycompat.py @ 43554: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 | fe73ec69350e |
comparison
equal
deleted
inserted
replaced
43553:47fac1692ede | 43554:9f70512ae2cf |
---|---|
17 import shlex | 17 import shlex |
18 import sys | 18 import sys |
19 import tempfile | 19 import tempfile |
20 | 20 |
21 ispy3 = sys.version_info[0] >= 3 | 21 ispy3 = sys.version_info[0] >= 3 |
22 ispypy = r'__pypy__' in sys.builtin_module_names | 22 ispypy = '__pypy__' in sys.builtin_module_names |
23 | 23 |
24 if not ispy3: | 24 if not ispy3: |
25 import cookielib | 25 import cookielib |
26 import cPickle as pickle | 26 import cPickle as pickle |
27 import httplib | 27 import httplib |
149 # On Windows, the native argv is unicode and is converted to MBCS bytes | 149 # On Windows, the native argv is unicode and is converted to MBCS bytes |
150 # since we do enable the legacy filesystem encoding. | 150 # since we do enable the legacy filesystem encoding. |
151 if getattr(sys, 'argv', None) is not None: | 151 if getattr(sys, 'argv', None) is not None: |
152 sysargv = list(map(os.fsencode, sys.argv)) | 152 sysargv = list(map(os.fsencode, sys.argv)) |
153 | 153 |
154 bytechr = struct.Struct(r'>B').pack | 154 bytechr = struct.Struct('>B').pack |
155 byterepr = b'%r'.__mod__ | 155 byterepr = b'%r'.__mod__ |
156 | 156 |
157 class bytestr(bytes): | 157 class bytestr(bytes): |
158 """A bytes which mostly acts as a Python 2 str | 158 """A bytes which mostly acts as a Python 2 str |
159 | 159 |
498 # mode must include 'b'ytes as encoding= is not supported | 498 # mode must include 'b'ytes as encoding= is not supported |
499 def namedtempfile( | 499 def namedtempfile( |
500 mode=b'w+b', bufsize=-1, suffix=b'', prefix=b'tmp', dir=None, delete=True | 500 mode=b'w+b', bufsize=-1, suffix=b'', prefix=b'tmp', dir=None, delete=True |
501 ): | 501 ): |
502 mode = sysstr(mode) | 502 mode = sysstr(mode) |
503 assert r'b' in mode | 503 assert 'b' in mode |
504 return tempfile.NamedTemporaryFile( | 504 return tempfile.NamedTemporaryFile( |
505 mode, bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete | 505 mode, bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete |
506 ) | 506 ) |