mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-104658: Fix location of unclosed quote error for multiline f-strings (#104660)
This commit is contained in:
parent
663c049ff7
commit
ff7f731632
3 changed files with 21 additions and 3 deletions
|
@ -1558,7 +1558,21 @@ x = (
|
|||
self.assertAllRaise(SyntaxError, "unterminated f-string literal", ['f"', "f'"])
|
||||
self.assertAllRaise(SyntaxError, "unterminated triple-quoted f-string literal",
|
||||
['f"""', "f'''"])
|
||||
|
||||
# Ensure that the errors are reported at the correct line number.
|
||||
data = '''\
|
||||
x = 1 + 1
|
||||
y = 2 + 2
|
||||
z = f"""
|
||||
sdfjnsdfjsdf
|
||||
sdfsdfs{1+
|
||||
2} dfigdf {3+
|
||||
4}sdufsd""
|
||||
'''
|
||||
try:
|
||||
compile(data, "?", "exec")
|
||||
except SyntaxError as e:
|
||||
self.assertEqual(e.text, 'z = f"""')
|
||||
self.assertEqual(e.lineno, 3)
|
||||
def test_syntax_error_after_debug(self):
|
||||
self.assertAllRaise(SyntaxError, "f-string: expecting a valid expression after '{'",
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue