mirror of
https://github.com/davidhalter/parso.git
synced 2026-10-18 11:51:26 +08:00
Add issue 'nonlocal declaration not allowed at module level'
This commit is contained in:
1 parent
87ce5fa9a4
commit
186160b9ff
3 files changed
+9
No files matched your search
@@ -313,6 +313,10 @@ class ErrorFinder(Normalizer):
|
|||||||
# f(+x=1)
|
# f(+x=1)
|
||||||
message = "keyword can't be an expression"
|
message = "keyword can't be an expression"
|
||||||
self._add_syntax_error(message, first)
|
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
|
yield
|
||||||
|
|
||||||
|
|||||||
@@ -45,3 +45,7 @@ except:
|
|||||||
pass
|
pass
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class X():
|
||||||
|
nonlocal a
|
||||||
@@ -105,6 +105,7 @@ def test_indentation_errors(code, positions):
|
|||||||
# SyntaxErrors from Python/symtable.c
|
# SyntaxErrors from Python/symtable.c
|
||||||
'def f(x, x): pass',
|
'def f(x, x): pass',
|
||||||
'def x(): from math import *',
|
'def x(): from math import *',
|
||||||
|
'nonlocal a',
|
||||||
|
|
||||||
# IndentationError
|
# IndentationError
|
||||||
' foo',
|
' foo',
|
||||||
|
|||||||
Reference in new issue
Block a user