Patchwork [py3] regex: make the regular expression bytes to prevent TypeError

login
register
mail settings
Submitter Pulkit Goyal
Date March 19, 2017, 8:25 a.m.
Message ID <0b63c5f5bb298086e4d8.1489911949@pulkit-goyal>
Download mbox | patch
Permalink /patch/19447/
State Accepted
Headers show

Comments

Pulkit Goyal - March 19, 2017, 8:25 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489707658 -19800
#      Fri Mar 17 05:10:58 2017 +0530
# Node ID 0b63c5f5bb298086e4d847941943b007ce7bec63
# Parent  e0e1c056226ea2cac3e3a312b1455d37d8ae8d6c
regex: make the regular expression bytes to prevent TypeError
Yuya Nishihara - March 19, 2017, 2:26 p.m.
On Sun, 19 Mar 2017 13:55:49 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489707658 -19800
> #      Fri Mar 17 05:10:58 2017 +0530
> # Node ID 0b63c5f5bb298086e4d847941943b007ce7bec63
> # Parent  e0e1c056226ea2cac3e3a312b1455d37d8ae8d6c
> regex: make the regular expression bytes to prevent TypeError

Queued this, thanks.

Patch

diff -r e0e1c056226e -r 0b63c5f5bb29 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Thu Mar 16 10:11:21 2017 +0530
+++ b/mercurial/dispatch.py	Fri Mar 17 05:10:58 2017 +0530
@@ -286,7 +286,7 @@ 
             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)
diff -r e0e1c056226e -r 0b63c5f5bb29 mercurial/posix.py
--- a/mercurial/posix.py	Thu Mar 16 10:11:21 2017 +0530
+++ b/mercurial/posix.py	Fri Mar 17 05:10:58 2017 +0530
@@ -408,7 +408,7 @@ 
         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