Message119603
Yes, but in that particular case the exact line referenced is involved in the error, since it that error is that the symbol is both nonlocal and an argument, and the error points to the head of the block which is the 'def' statement.
Attached is a patch that adds the available line info, and also modifies the 'nonlocal at global level' message to include the symbol name.
I think this change is a good idea because without the patch this code:
>cat temp
import foo
>cat foo.py
def f():
def g():
nonlocal a
gives this:
>./python temp
Traceback (most recent call last):
File "temp", line 1, in <module>
import foo
SyntaxError: no binding for nonlocal 'a' found
which is even more confusing that not having any traceback at all.
After the patch it will look like this:
Traceback (most recent call last):
File "temp", line 1, in <module>
import foo
File "/home/rdmurray/python/py3k/foo.py", line 2
def g():
SyntaxError: no binding for nonlocal 'a' found |
|
Date |
User |
Action |
Args |
2010-10-26 12:00:07 | r.david.murray | set | recipients:
+ r.david.murray, jhylton, georg.brandl, benjamin.peterson, alex |
2010-10-26 12:00:07 | r.david.murray | set | messageid: <1288094407.14.0.650582015449.issue10189@psf.upfronthosting.co.za> |
2010-10-26 12:00:00 | r.david.murray | link | issue10189 messages |
2010-10-26 12:00:00 | r.david.murray | create | |
|