[New-bugs-announce] [issue13827] Unexecuted import changes namespace
Michael Hipp
report at bugs.python.org
Thu Jan 19 17:02:19 CET 2012
New submission from Michael Hipp <michael at redmule.com>:
A local *unexecuted* import appears to be changing the namespace. Attached files are ready to run.
# over.py
SOMETHING = "overridden"
# main.py
OVERRIDE = False
SOMETHING = "original"
def main():
#global SOMETHING # uncomment and it works
if OVERRIDE:
from over import SOMETHING # comment out and it works
pass
print SOMETHING # UnboundLocalError: local variable 'SOMETHING' referenced before assignment
The SOMETHING variable has a value from the module global namespace, but it gets lost due to an import that is never executed.
I would think an unexecuted statement shouldn't have any effect on anything.
The second file will have to be submitted in a follow-on, it appears
----------
components: None
files: main.py
messages: 151635
nosy: hippmr
priority: normal
severity: normal
status: open
title: Unexecuted import changes namespace
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file24278/main.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13827>
_______________________________________
More information about the New-bugs-announce
mailing list