[3.11] gh-92858: Improve error message for some suites with syntax error before ':' (GH-92894) (#94180)

(cherry picked from commit 2fc83ac3af)

Co-authored-by: wookie184 <wookie1840@gmail.com>

Co-authored-by: wookie184 <wookie1840@gmail.com>
This commit is contained in:
Pablo Galindo Salgado 2022-06-23 18:38:06 +01:00 committed by GitHub
parent ee82f0f314
commit 65ed8b47ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 728 additions and 566 deletions

View file

@ -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