summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-12-07 09:18:00 (GMT)
committerGitHub <noreply@github.com>2022-12-07 09:18:00 (GMT)
commit2b97ddd5122c016bd090ed187479606205b6b1a4 (patch)
tree41d505ac6d89868b119d557cc6018bd20c8e0e18 /Lib/test/test_syntax.py
parentfbc3e1ed90b9ce758d58fe88048690335799f140 (diff)
downloadcpython-2b97ddd5122c016bd090ed187479606205b6b1a4.zip
cpython-2b97ddd5122c016bd090ed187479606205b6b1a4.tar.gz
cpython-2b97ddd5122c016bd090ed187479606205b6b1a4.tar.bz2
gh-100050: Fix an assertion error when raising unclosed parenthesis errors in the tokenizer (GH-100065)
(cherry picked from commit 97e7004cfe48305bcd642c653b406dc7470e196d) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> 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 400092e..42d36e0 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -2095,6 +2095,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")