Patchwork D1538: py3: add b'' to regular expressions which are raw strings

login
register
mail settings
Submitter phabricator
Date Nov. 29, 2017, 1:43 a.m.
Message ID <700c9003d0fc2cab70cefb1b07146145@localhost.localdomain>
Download mbox | patch
Permalink /patch/25794/
State Not Applicable
Headers show

Comments

phabricator - Nov. 29, 2017, 1:43 a.m.
pulkit updated this revision to Diff 3955.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1538?vs=3951&id=3955

REVISION DETAIL
  https://phab.mercurial-scm.org/D1538

AFFECTED FILES
  hgext/mq.py
  mercurial/dispatch.py
  mercurial/util.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2667,7 +2667,7 @@ 
         else:
             prefix_char = prefix
         mapping[prefix_char] = prefix_char
-    r = remod.compile(r'%s(%s)' % (prefix, patterns))
+    r = remod.compile(br'%s(%s)' % (prefix, patterns))
     return r.sub(lambda x: fn(mapping[x.group()[1:]]), s)
 
 def getport(port):
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -404,7 +404,7 @@ 
     # tokenize each argument into exactly one word.
     replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args)
     # escape '\$' for regex
-    regex = '|'.join(replacemap.keys()).replace('$', r'\$')
+    regex = '|'.join(replacemap.keys()).replace('$', br'\$')
     r = re.compile(regex)
     return r.sub(lambda x: replacemap[x.group()], cmd)
 
@@ -449,7 +449,7 @@ 
                                  "of %i variable in alias '%s' definition."
                                  % (int(m.groups()[0]), self.name))
                         return ''
-                cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:])
+                cmd = re.sub(br'\$(\d+|\$)', _checkvar, self.definition[1:])
                 cmd = aliasinterpolate(self.name, args, cmd)
                 return ui.system(cmd, environ=env,
                                  blockedtag='alias_%s' % self.name)
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -565,7 +565,7 @@ 
                 return index
         return None
 
-    guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
+    guard_re = re.compile(br'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
 
     def parseseries(self):
         self.series = []