[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Ezio Melotti
Changes by Ezio Melotti : -- components: -None resolution: -> invalid stage: -> committed/rejected status: open -> closed ___ Python tracker ___ __

[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Ezio Melotti
Ezio Melotti added the comment: >>> OVERRIDE = False >>> SOMETHING = "original" >>> >>> def main(): ... if OVERRIDE: ... SOMETHING = None ... print SOMETHING ... >>> main() Traceback (most recent call last): File "", line 1, in File "", line 4, in main UnboundLocalError: l

[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Michael Foord
Michael Foord added the comment: hippmr: the problem is that by importing SOMETHING inside that function you're creating a *local variable* called SOMETHING. If the override isn't executed, and SOMETHING isn't global, then that local variable doesn't exist - which is why you get that error.

[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Michael Hipp
Michael Hipp added the comment: Even an *unexecuted* import assignment statement? -- resolution: invalid -> status: closed -> open ___ Python tracker ___ __

[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Benjamin Peterson
Benjamin Peterson added the comment: Not a bug. Basically, import is an explicit assignment statement. -- nosy: +benjamin.peterson resolution: -> invalid status: open -> closed ___ Python tracker

[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Michael Hipp
Michael Hipp added the comment: Add'l over.py file -- Added file: http://bugs.python.org/file24279/over.py ___ Python tracker ___ ___

[issue13827] Unexecuted import changes namespace

2012-01-19 Thread Michael Hipp
New submission from Michael Hipp : 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 OVERRID