Don't crash when nonlocal is used at module level (fixes SF#1705365)

This commit is contained in:
Nick Coghlan 2007-04-23 10:14:27 +00:00
parent 846f1ee390
commit 4138bfec0a
2 changed files with 16 additions and 5 deletions

View file

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