mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
make recording and reporting errors and nonlocal and global directives more robust (closes #25973)
This commit is contained in:
parent
01f7ac3bb0
commit
3cc8f4b969
3 changed files with 27 additions and 8 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue