summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-09 14:45:43 -0700
committerGitHub <noreply@github.com>2021-06-09 14:45:43 -0700
commitf807a4fad4da8f629ea7fe1f00719e817c77b63c (patch)
tree1ef8fc5c3cf24eb407f7a3e8be9ee684c9920200 /Lib/test
parent664ae29e6f61988e74cb8753dd4ee71e9ea57227 (diff)
downloadcpython-git-f807a4fad4da8f629ea7fe1f00719e817c77b63c.tar.gz
bpo-44368: Ensure we don't raise incorrect custom syntax errors with soft keywords (GH-26630)
(cherry picked from commit 457ce60fc70f1c9290023f46fb82b6a490dff32e) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_exceptions.py1
-rw-r--r--Lib/test/test_syntax.py20
2 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index b242c082f8..9cb5466a67 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -215,6 +215,7 @@ class ExceptionTests(unittest.TestCase):
check('[\nfile\nfor str(file)\nin\n[]\n]', 3, 5)
check('[file for\n str(file) in []]', 2, 2)
check("ages = {'Alice'=22, 'Bob'=23}", 1, 16)
+ check('match ...:\n case {**rest, "key": value}:\n ...', 2, 19)
# Errors thrown by compile.c
check('class foo:return 1', 1, 11)
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 5d3ce4cd9f..72e4ab15c8 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -267,7 +267,7 @@ Traceback (most recent call last):
SyntaxError: invalid syntax. Perhaps you forgot a comma?
# Make sure soft keywords constructs don't raise specialized
-# errors regarding missing commas
+# errors regarding missing commas or other spezialiced errors
>>> match x:
... y = 3
@@ -280,6 +280,24 @@ SyntaxError: invalid syntax
Traceback (most recent call last):
SyntaxError: invalid syntax
+>>> match x:
+... case $:
+... ...
+Traceback (most recent call last):
+SyntaxError: invalid syntax
+
+>>> match ...:
+... case {**rest, "key": value}:
+... ...
+Traceback (most recent call last):
+SyntaxError: invalid syntax
+
+>>> match ...:
+... case {**_}:
+... ...
+Traceback (most recent call last):
+SyntaxError: invalid syntax
+
From compiler_complex_args():
>>> def f(None=1):