This commit is contained in:
Kovid Goyal 2022-07-14 21:29:00 +05:30
commit ea8e8cedb3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
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')