make recording and reporting errors and nonlocal and global directives more robust (closes #25973)

This commit is contained in:
Benjamin Peterson 2015-12-29 10:08:34 -06:00
parent 01f7ac3bb0
commit 3cc8f4b969
3 changed files with 27 additions and 8 deletions

View file

@ -416,6 +416,14 @@ TODO(jhylton): Figure out how to test SyntaxWarning with doctest.
## ...
## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
From https://bugs.python.org/issue25973
>>> class A:
... def f(self):
... nonlocal __x
Traceback (most recent call last):
...
SyntaxError: no binding for nonlocal '_A__x' found
This tests assignment-context; there was a bug in Python 2.5 where compiling
a complex 'if' (one with 'elif') would fail to notice an invalid suite,