bpo-42986: Fix parser crash when reporting syntax errors in f-string with newlines (GH-24279)

This commit is contained in:
Pablo Galindo 2021-01-31 22:48:23 +00:00 • committed by GitHub
parent a1e9a1e120
commit 4090151816
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -664,6 +664,9 @@ x = (
self.assertAllRaise(SyntaxError, 'unterminated string literal',
["f'{\n}'",
])
def test_newlines_before_syntax_error(self):
self.assertAllRaise(SyntaxError, "invalid syntax",
["f'{.}'", "\nf'{.}'", "\n\nf'{.}'"])
def test_backslashes_in_string_part(self):
self.assertEqual(f'\t', '\t')