[issue10043] UnboundLocalError with local variable set by setattr, caused by code run later

Steven Samuel Cole report at bugs.python.org
Thu Oct 7 14:08:35 CEST 2010


Steven Samuel Cole <steven.samuel.cole at gmail.com> added the comment:

I'm just a developer, I don't know anything about Python internals or what Python sees or does at what stage.

Looking at the sample file, code executed later has an influence on code executed earlier - and that behavior is unexpected, confusing, bizarre, no matter what expert explanations there are.

It took me a while to isolate this problem, thought I report it here to save others the effort. This should at least be mentioned in the docs somewhere around setattr(...).

I think it is premature to declare this report invalid and close the bug - but hey, if _you_ are not interested in improving Python wherever possible, why would _I_ be ?

----------

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


More information about the Python-bugs-list mailing list