summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorwookie184 <wookie1840@gmail.com>2022-06-23 16:31:09 (GMT)
committerGitHub <noreply@github.com>2022-06-23 16:31:09 (GMT)
commit2fc83ac3afa161578200dbf8d823a20e0801c0c0 (patch)
tree056d63ec8f5152ac1086702e4a6f746a90d2c8a6 /Lib
parentb4e0d6124a848a22df1ba12891329242c9e96f11 (diff)
downloadcpython-2fc83ac3afa161578200dbf8d823a20e0801c0c0.zip
cpython-2fc83ac3afa161578200dbf8d823a20e0801c0c0.tar.gz
cpython-2fc83ac3afa161578200dbf8d823a20e0801c0c0.tar.bz2
gh-92858: Improve error message for some suites with syntax error before ':' (#92894)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_syntax.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 96e5c12..a9193b0 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -607,7 +607,7 @@ SyntaxError: Generator expression must be parenthesized
>>> class C(x for x in L):
... pass
Traceback (most recent call last):
-SyntaxError: expected ':'
+SyntaxError: invalid syntax
>>> def g(*args, **kwargs):
... print(args, sorted(kwargs.items()))
@@ -963,17 +963,22 @@ leading to spurious errors.
...
SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?
- Missing ':' before suites:
+Missing ':' before suites:
- >>> def f()
- ... pass
- Traceback (most recent call last):
- SyntaxError: expected ':'
+ >>> def f()
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
- >>> class A
- ... pass
- Traceback (most recent call last):
- SyntaxError: expected ':'
+ >>> class A
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
+
+ >>> class R&D:
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
>>> if 1
... pass
@@ -1007,6 +1012,11 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> for x in range 10:
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+
>>> while True
... pass
Traceback (most recent call last):
@@ -1052,6 +1062,11 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> with block ad something:
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+
>>> try
... pass
Traceback (most recent call last):
@@ -1070,6 +1085,12 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> match x x:
+ ... case list():
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+
>>> match x:
... case list()
... pass