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

Pulkit Goyal 7895pulkit at gmail.com
Sun Mar 12 01:40:36 UTC 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1489282177 -19800
#      Sun Mar 12 06:59:37 2017 +0530
# Node ID 8a0ab8f9e6a51af702e9477664c640ae271c05d2
# Parent  62939e0148f170b67ca8c7374f36c413b67fd387
minirst: make regular expressions bytes

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


More information about the Mercurial-devel mailing list