Fix for a stupid oversight in the docstring stuff. I left DOTALL off the replace. :(

Here is a fix and a test for the fix.
This commit is contained in:
Charles Haley 2022-07-14 16:57:24 +01:00
parent e98c1fdc8e
commit dbc97f3b6b
2 changed files with 3 additions and 1 deletions

View File

@ -194,7 +194,8 @@ class Parser:
# convert docstrings to base64 to avoid all processing. Change the docstring # convert docstrings to base64 to avoid all processing. Change the docstring
# indicator to something unique with no characters special to the parser. # indicator to something unique with no characters special to the parser.
expr = re.sub('(""")(..*?)(""")', expr = re.sub('(""")(..*?)(""")',
lambda mo: self.docstring_sep + as_hex_unicode(mo.group(2)) + self.docstring_sep, expr) lambda mo: self.docstring_sep + as_hex_unicode(mo.group(2)) + self.docstring_sep,
expr, flags=re.DOTALL)
# Strip out escaped backslashes, quotes and parens so that the # Strip out escaped backslashes, quotes and parens so that the
# lex scanner doesn't get confused. We put them back later. # lex scanner doesn't get confused. We put them back later.

View File

@ -391,6 +391,7 @@ class TestSQP(unittest.TestCase):
t(r'("""a\1b""" AND """c""" OR d)', t(r'("""a\1b""" AND """c""" OR d)',
'O', '(', 'W', r'a\1b', 'W', 'AND', 'W', 'c', 'W', 'OR', 'W', 'd', 'O', ')') 'O', '(', 'W', r'a\1b', 'W', 'AND', 'W', 'c', 'W', 'OR', 'W', 'd', 'O', ')')
t(r'template:="""a\1b"""', 'W', r'template:=a\1b') t(r'template:="""a\1b"""', 'W', r'template:=a\1b')
t('template:="""a\nb"""', 'W', 'template:=a\nb')
t(r'template:"""=a\1b"""', 'W', r'template:=a\1b') t(r'template:"""=a\1b"""', 'W', r'template:=a\1b')
t(r'template:"""program: return ("\"1\"")#@#n:1"""', 'W', t(r'template:"""program: return ("\"1\"")#@#n:1"""', 'W',
r'template:program: return ("\"1\"")#@#n:1') r'template:program: return ("\"1\"")#@#n:1')