[New-bugs-announce] [issue10043] UnboundLocalError with local variable set by setattr, caused by code run later
Steven Samuel Cole
report at bugs.python.org
Thu Oct 7 12:13:50 CEST 2010
New submission from Steven Samuel Cole <steven.samuel.cole at gmail.com>:
inside a function, I create a local variable by using setattr with the current module as object, as in
setattr(modules[__name__], 'name', 'value')
if I _later_ in the code set name to None, the attribute becomes unavailable even for code that is executed _before_ setting name to None.
please also see sample file.
components: Interpreter Core
title: UnboundLocalError with local variable set by setattr, caused by code run later
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file19146/show_weird_behavior.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce