mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)
This commit is contained in:
parent
b0544ba77c
commit
56c95dfe27
6 changed files with 2230 additions and 599 deletions
|
@ -926,6 +926,138 @@ Incomplete dictionary literals
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
Specialized indentation errors:
|
||||
|
||||
>>> while condition:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'while' statement on line 1
|
||||
|
||||
>>> for x in range(10):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'for' statement on line 1
|
||||
|
||||
>>> for x in range(10):
|
||||
... pass
|
||||
... else:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'else' statement on line 3
|
||||
|
||||
>>> async for x in range(10):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'for' statement on line 1
|
||||
|
||||
>>> async for x in range(10):
|
||||
... pass
|
||||
... else:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'else' statement on line 3
|
||||
|
||||
>>> if something:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'if' statement on line 1
|
||||
|
||||
>>> if something:
|
||||
... pass
|
||||
... elif something_else:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'elif' statement on line 3
|
||||
|
||||
>>> if something:
|
||||
... pass
|
||||
... elif something_else:
|
||||
... pass
|
||||
... else:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'else' statement on line 5
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'try' statement on line 1
|
||||
|
||||
>>> try:
|
||||
... something()
|
||||
... except A:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'except' statement on line 3
|
||||
|
||||
>>> try:
|
||||
... something()
|
||||
... except A:
|
||||
... pass
|
||||
... finally:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'finally' statement on line 5
|
||||
|
||||
>>> with A:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'with' statement on line 1
|
||||
|
||||
>>> with A as a, B as b:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'with' statement on line 1
|
||||
|
||||
>>> with (A as a, B as b):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'with' statement on line 1
|
||||
|
||||
>>> async with A:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'with' statement on line 1
|
||||
|
||||
>>> async with A as a, B as b:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'with' statement on line 1
|
||||
|
||||
>>> async with (A as a, B as b):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'with' statement on line 1
|
||||
|
||||
>>> def foo(x, /, y, *, z=2):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after function definition on line 1
|
||||
|
||||
>>> class Blech(A):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after class definition on line 1
|
||||
|
||||
>>> match something:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'match' statement on line 1
|
||||
|
||||
>>> match something:
|
||||
... case []:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'case' statement on line 2
|
||||
|
||||
>>> match something:
|
||||
... case []:
|
||||
... ...
|
||||
... case {}:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
IndentationError: expected an indented block after 'case' statement on line 4
|
||||
|
||||
Make sure that the old "raise X, Y[, Z]" form is gone:
|
||||
>>> raise X, Y
|
||||
Traceback (most recent call last):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue