gh-103656: Transfer f-string buffers to parser to avoid use-after-free (GH-103896)

Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
Lysandros Nikolaou 2023-04-26 19:33:31 -06:00 committed by GitHub
parent 76632b836c
commit 9169a56fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 146 additions and 66 deletions

View file

@ -1535,5 +1535,19 @@ x = (
self.assertAllRaise(SyntaxError, "unterminated triple-quoted f-string literal",
['f"""', "f'''"])
def test_syntax_error_after_debug(self):
self.assertAllRaise(SyntaxError, "f-string: expecting a valid expression after '{'",
[
"f'{1=}{;'",
"f'{1=}{+;'",
"f'{1=}{2}{;'",
"f'{1=}{3}{;'",
])
self.assertAllRaise(SyntaxError, "f-string: expecting '=', or '!', or ':', or '}'",
[
"f'{1=}{1;'",
"f'{1=}{1;}'",
])
if __name__ == '__main__':
unittest.main()