py3: make the regular expression bytes to prevent TypeError
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 17 Mar 2017 05:10:58 +0530
changeset 36472 492c64afc54c3911df2304dbcf873a5b2b9e205c
parent 36471 8122cc5cb54328eaa2ca1e769da520979f55b852
child 36473 3c77414a0f9c38ba6b1eacfb6561fa0b41bfe95a
push id475
push usergszorc@mozilla.com
push dateSun, 19 Mar 2017 19:02:00 +0000
py3: make the regular expression bytes to prevent TypeError
mercurial/dispatch.py
mercurial/posix.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -281,17 +281,17 @@ def aliasargs(fn, givenargs):
 
         nums = []
         def replacer(m):
             num = int(m.group(1)) - 1
             nums.append(num)
             if num < len(givenargs):
                 return givenargs[num]
             raise error.Abort(_('too few arguments for command alias'))
-        cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
+        cmd = re.sub(br'\$(\d+|\$)', replacer, cmd)
         givenargs = [x for i, x in enumerate(givenargs)
                      if i not in nums]
         args = pycompat.shlexsplit(cmd)
     return args + givenargs
 
 def aliasinterpolate(name, args, cmd):
     '''interpolate args into cmd for shell aliases
 
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -403,17 +403,17 @@ if pycompat.sysplatform == 'cygwin':
         return False
 
 _needsshellquote = None
 def shellquote(s):
     if pycompat.sysplatform == 'OpenVMS':
         return '"%s"' % s
     global _needsshellquote
     if _needsshellquote is None:
-        _needsshellquote = re.compile(r'[^a-zA-Z0-9._/+-]').search
+        _needsshellquote = re.compile(br'[^a-zA-Z0-9._/+-]').search
     if s and not _needsshellquote(s):
         # "s" shouldn't have to be quoted
         return s
     else:
         return "'%s'" % s.replace("'", "'\\''")
 
 def quotecommand(cmd):
     return cmd