mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Don't crash when nonlocal is used at module level (fixes SF#1705365)
This commit is contained in:
parent
846f1ee390
commit
4138bfec0a
2 changed files with 16 additions and 5 deletions
|
@ -388,6 +388,12 @@ Misuse of the nonlocal statement can lead to a few unique syntax errors.
|
|||
...
|
||||
SyntaxError: no binding for nonlocal 'x' found
|
||||
|
||||
From SF bug #1705365
|
||||
>>> nonlocal x
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SyntaxError: nonlocal declaration not allowed at module level
|
||||
|
||||
TODO(jhylton): Figure out how to test SyntaxWarning with doctest.
|
||||
|
||||
## >>> def f(x):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue