[New-bugs-announce] [issue8515] idle "Run Module" (F5) does not set __file__ variable

Bruce Frederiksen report at bugs.python.org
Sat Apr 24 03:18:10 CEST 2010

New submission from Bruce Frederiksen <dangyogi at gmail.com>:

The python CLI always sets the __file__ variable, whether run as:

$ python foobar.py


$ python -m foobar


$ python
>>> import foobar   # __file__ set in foobar module

The idle program sets the __file__ variable properly when you do the import from the idle shell, but __file__ is not set with the "Run Module" (F5) command from the editor.

I've included a patch file to set __file__, but it doesn't del it after the module has run.  But maybe this is OK, because the os.chdir is not undone either???

components: IDLE
files: idle.patch
keywords: patch
messages: 104066
nosy: dangyogi
severity: normal
status: open
title: idle "Run Module" (F5) does not set __file__ variable
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file17062/idle.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list