[issue28936] test_global_err_then_warn in test_syntax is no longer valid
Ivan Levkivskyi
report at bugs.python.org
Sun Dec 11 09:15:15 EST 2016
Ivan Levkivskyi added the comment:
Serhiy, here is a patch that might be helpful. It detects global-and-parameter errors sooner (when possible). This will cause the following:
>>> if 1:
... def error(a):
... global a
... def error2():
... b = 1
... global b
...
File "<stdin>", line 3
SyntaxError: name 'a' is parameter and global
However, in more complex (nested) cases, the global-after-assign will still be detected sooner:
>>> def error(a):
... def inner():
... global a
... def inner2():
... b = 1
... global b
...
File "<stdin>", line 6
SyntaxError: name 'b' is assigned to before global declaration
Maybe there is a way to delay the detection of this error until second pass in symtable.c, but don't see now how to do this.
----------
keywords: +patch
Added file: http://bugs.python.org/file45849/syntax-error-order.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28936>
_______________________________________
More information about the Python-bugs-list
mailing list