Add issue 'nonlocal declaration not allowed at module level'

This commit is contained in:
Dave Halter
2017-07-25 22:29:09 +02:00
parent 87ce5fa9a4
commit 186160b9ff
3 changed files with 9 additions and 0 deletions

View File

@@ -313,6 +313,10 @@ class ErrorFinder(Normalizer):
# f(+x=1)
message = "keyword can't be an expression"
self._add_syntax_error(message, first)
elif node.type == 'nonlocal_stmt':
if self._context.parent_context is None:
message = "nonlocal declaration not allowed at module level"
self._add_syntax_error(message, node)
yield