summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fstring.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-05-20 13:07:05 (GMT)
committerGitHub <noreply@github.com>2023-05-20 13:07:05 (GMT)
commitff7f7316326a19749c5d79f9e44acdbe7d54ac4e (patch)
treef6dac134867ada4b1297bda44c91b6dbe3a4f3bc /Lib/test/test_fstring.py
parent663c049ff78a299bdf7c1a0444b9900e6d37372d (diff)
downloadcpython-ff7f7316326a19749c5d79f9e44acdbe7d54ac4e.zip
cpython-ff7f7316326a19749c5d79f9e44acdbe7d54ac4e.tar.gz
cpython-ff7f7316326a19749c5d79f9e44acdbe7d54ac4e.tar.bz2
gh-104658: Fix location of unclosed quote error for multiline f-strings (#104660)
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r--Lib/test/test_fstring.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 58e2550..fcb12d2 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -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 '{'",
[