[issue4617] SyntaxError when free variable name is also an exception target

Terry J. Reedy report at bugs.python.org
Sat Dec 13 00:03:45 CET 2008


Terry J. Reedy <tjreedy at udel.edu> added the comment:

-1 as I understand the proposal.  Your code is bugged and should fail as
soon as possible.

If I understand correctly, you agree that the SyntaxError is correct as
the language is currently defined, but you want the definition changed.
It is not clear if you only want implicit deletes at the end of except
clauses to work or if you only want explicit deletes to work.

If the latter, you want

def f():
  e = 1
  del e
  def g(): print(e)
  return g

to compile. I would not.  Your reason "After all, the "variable
referenced" has no value before it is set," (duh, right) makes no sense
to me in this context.  g must have a valid value of e to run.  So you
seem to be suggesting that detection of buggy code should be delayed.

----------
nosy: +tjreedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4617>
_______________________________________


More information about the Python-bugs-list mailing list