mirror of
https://github.com/python/cpython.git
synced 2025-10-24 02:13:49 +00:00
gh-129858: Special syntax error for elif block after else (#129902)
This commit is contained in:
parent
c3a7118065
commit
99b71efe8e
5 changed files with 137 additions and 75 deletions
|
|
@ -948,6 +948,18 @@
|
|||
...
|
||||
SyntaxError: 'break' outside loop
|
||||
|
||||
elif can't come after an else.
|
||||
|
||||
>>> if a % 2 == 0:
|
||||
... pass
|
||||
... else:
|
||||
... pass
|
||||
... elif a % 2 == 1:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SyntaxError: 'elif' block follows an 'else' block
|
||||
|
||||
Misuse of the nonlocal and global statement can lead to a few unique syntax errors.
|
||||
|
||||
>>> def f():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue