diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-04-15 21:38:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 21:38:45 +0100 |
commit | b280248be8e648feb82f3f3ed0050e50b238df7b (patch) | |
tree | fee5117cd4e2111d701422c52e30f3b85349b1a9 /Lib/test/test_syntax.py | |
parent | e692f55979980826a5281560c534ef399a8f9848 (diff) | |
download | cpython-b280248be8e648feb82f3f3ed0050e50b238df7b.tar.gz cpython-b280248be8e648feb82f3f3ed0050e50b238df7b.zip |
bpo-43822: Improve syntax errors for missing commas (GH-25377)
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 75b778d20e9..4d8198e5db6 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -248,22 +248,36 @@ SyntaxError: did you forget parentheses around the comprehension target? # Missing commas in literals collections should not # produce special error messages regarding missing -# parentheses +# parentheses, but about missing commas instead >>> [1, 2 3] Traceback (most recent call last): -SyntaxError: invalid syntax +SyntaxError: invalid syntax. Perhaps you forgot a comma? >>> {1, 2 3} Traceback (most recent call last): -SyntaxError: invalid syntax +SyntaxError: invalid syntax. Perhaps you forgot a comma? >>> {1:2, 2:5 3:12} Traceback (most recent call last): -SyntaxError: invalid syntax +SyntaxError: invalid syntax. Perhaps you forgot a comma? >>> (1, 2 3) 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 + +>>> match x: +... y = 3 +Traceback (most recent call last): +SyntaxError: invalid syntax + +>>> match x: +... case y: +... 3 $ 3 +Traceback (most recent call last): SyntaxError: invalid syntax From compiler_complex_args(): @@ -864,7 +878,7 @@ leading to spurious errors. SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='? Ensure that early = are not matched by the parser as invalid comparisons - >>> f(2, 4, x=34); {1,2 a} + >>> f(2, 4, x=34); 1 $ 2 Traceback (most recent call last): SyntaxError: invalid syntax |