Patchwork [1,of,2,py3] minirst: make regular expressions bytes

login
register
mail settings
Submitter Pulkit Goyal
Date March 12, 2017, 1:40 a.m.
Message ID <8a0ab8f9e6a51af702e9.1489282836@pulkit-goyal>
Download mbox | patch
Permalink /patch/19129/
State Accepted
Headers show

Comments

Pulkit Goyal - March 12, 2017, 1:40 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489282177 -19800
#      Sun Mar 12 06:59:37 2017 +0530
# Node ID 8a0ab8f9e6a51af702e9477664c640ae271c05d2
# Parent  62939e0148f170b67ca8c7374f36c413b67fd387
minirst: make regular expressions bytes
Yuya Nishihara - March 12, 2017, 3:45 p.m.
On Sun, 12 Mar 2017 07:10:36 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489282177 -19800
> #      Sun Mar 12 06:59:37 2017 +0530
> # Node ID 8a0ab8f9e6a51af702e9477664c640ae271c05d2
> # Parent  62939e0148f170b67ca8c7374f36c413b67fd387
> minirst: make regular expressions bytes

Looks good, queued, thanks.

Patch

diff -r 62939e0148f1 -r 8a0ab8f9e6a5 mercurial/minirst.py
--- a/mercurial/minirst.py	Wed Mar 08 18:11:41 2017 -0500
+++ b/mercurial/minirst.py	Sun Mar 12 06:59:37 2017 +0530
@@ -64,7 +64,7 @@ 
         utext = utext.replace(f.decode("ascii"), t.decode("ascii"))
     return utext.encode(encoding.encoding)
 
-_blockre = re.compile(r"\n(?:\s*\n)+")
+_blockre = re.compile(br"\n(?:\s*\n)+")
 
 def findblocks(text):
     """Find continuous blocks of lines in text.
@@ -138,12 +138,12 @@ 
         i += 1
     return blocks
 
-_bulletre = re.compile(r'(\*|-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
-_optionre = re.compile(r'^(-([a-zA-Z0-9]), )?(--[a-z0-9-]+)'
-                       r'((.*)  +)(.*)$')
-_fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
-_definitionre = re.compile(r'[^ ]')
-_tablere = re.compile(r'(=+\s+)*=+')
+_bulletre = re.compile(br'(\*|-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
+_optionre = re.compile(br'^(-([a-zA-Z0-9]), )?(--[a-z0-9-]+)'
+                       br'((.*)  +)(.*)$')
+_fieldre = re.compile(br':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
+_definitionre = re.compile(br'[^ ]')
+_tablere = re.compile(br'(=+\s+)*=+')
 
 def splitparagraphs(blocks):
     """Split paragraphs into lists."""
@@ -286,7 +286,7 @@ 
         i += 1
     return blocks, pruned
 
-_sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""")
+_sectionre = re.compile(br"""^([-=`:.'"~^_*+#])\1+$""")
 
 def findtables(blocks):
     '''Find simple tables
@@ -432,7 +432,7 @@ 
     """
     admonitions = admonitions or _admonitions
 
-    admonitionre = re.compile(r'\.\. (%s)::' % '|'.join(sorted(admonitions)),
+    admonitionre = re.compile(br'\.\. (%s)::' % '|'.join(sorted(admonitions)),
                               flags=re.IGNORECASE)
 
     i = 0