Roundup Robot added the comment:
New changeset fbfaef0a9c00 by Benjamin Peterson in branch 'default':
point errors related to nonlocals and globals to the statement declaring them
(closes #10189)
http://hg.python.org/cpython/rev/fbfaef0a9c00
--
nosy: +python-dev
resolution: - fixed
R. David Murray rdmur...@bitdance.com added the comment:
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.
Changes by R. David Murray rdmur...@bitdance.com:
--
Removed message: http://bugs.python.org/msg119601
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10189
___
R. David Murray rdmur...@bitdance.com added the comment:
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.
R. David Murray rdmur...@bitdance.com added the comment:
Ah, I hadn't noticed Benjamin assigned this to himself when I submitted that
patch. Well, maybe it will be marginally useful anyway :)
--
___
Python tracker rep...@bugs.python.org
Georg Brandl ge...@python.org added the comment:
+1 for adding at least the info the symtable knows (this is already done in one
of the branches in that function that raises a SyntaxError).
--
nosy: +georg.brandl
___
Python tracker
Changes by Benjamin Peterson benja...@python.org:
--
assignee: - benjamin.peterson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10189
___
___
New submission from Alex alex.gay...@gmail.com:
Given the code:
def f():
def g():
nonlocal a
a = 3
Running it produces:
a...@alex-laptop:/tmp$ python3.1 test.py
SyntaxError: no binding for nonlocal 'a' found
Compared to a different SyntaxError:
a...@alex-laptop:/tmp$
R. David Murray rdmur...@bitdance.com added the comment:
There are a number of such symbol resolution error messages for nonlocal that
don't provide location information in symtable.c. I'm not very experienced
with hacking the C code, but a naive addition of location information based on
R. David Murray rdmur...@bitdance.com added the comment:
Hmm. Just to clarify, the commit message on the code in question specifically
said that the implementation of nonlocal was not complete with that commit, and
Jeremy wasn't the only one working on it. So this detail may have simply been
Benjamin Peterson benja...@python.org added the comment:
Technically, it's because the syntax errors come from a latter part of the
compiling phase when the origin of names isn't known. Fixing this would involve
attaching line numbers and offsets to names somehow.
--
nosy:
R. David Murray rdmur...@bitdance.com added the comment:
I figured it was something like that, from looking at the code.
I wonder if it would be worthwhile to return the line info that is known (which
I think is the start of the block containing the problematic symbol). In a
complex program
12 matches
Mail list logo