aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2022-12-06 23:09:56 +0000
committerGitHub <noreply@github.com>2022-12-06 15:09:56 -0800
commit97e7004cfe48305bcd642c653b406dc7470e196d (patch)
tree7cbdfd5e01f133d61f21d66d5add469968a452f5 /Lib/test/test_syntax.py
parentabbe4482ab914d6da8b1678ad46174cb875ed7f6 (diff)
downloadcpython-97e7004cfe48305bcd642c653b406dc7470e196d.tar.gz
cpython-97e7004cfe48305bcd642c653b406dc7470e196d.zip
gh-100050: Fix an assertion error when raising unclosed parenthesis errors in the tokenizer (GH-100065)
Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 78cac231929..cb284195d97 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -2145,6 +2145,22 @@ def func2():
for paren in ")]}":
self._check_error(paren + "1 + 2", f"unmatched '\\{paren}'")
+ # Some more complex examples:
+ code = """\
+func(
+ a=["unclosed], # Need a quote in this comment: "
+ b=2,
+)
+"""
+ self._check_error(code, "parenthesis '\\)' does not match opening parenthesis '\\['")
+
+ def test_error_string_literal(self):
+
+ self._check_error("'blech", "unterminated string literal")
+ self._check_error('"blech', "unterminated string literal")
+ self._check_error("'''blech", "unterminated triple-quoted string literal")
+ self._check_error('"""blech', "unterminated triple-quoted string literal")
+
def test_invisible_characters(self):
self._check_error('print\x17("Hello")', "invalid non-printable character")