[New-bugs-announce] [issue18288] Idle 2.7: Run Module does not set __file__
Terry J. Reedy
report at bugs.python.org
Sun Jun 23 21:10:49 CEST 2013
New submission from Terry J. Reedy:
This is a 2.7 only bug.
F:\Python\mypy\tem2.py
----
print (__file__)
__file__ should be set to relative or absolute path.
>From command line:
F:\Python\mypy> c:/programs/python27/python.exe tem2.py
tem2.py
F:\Python\mypy> c:/programs/python27/python.exe -m tem2
F:\Python\mypy\tem2.py
3.3 gives same results.
>From Idle editor window with Run Module (F5):
3.3: >>>
F:\Python\mypy\tem2.py
# same as python -m above, and same as when file is imported.
2.7: >>>
Traceback (most recent call last):
File "F:\Python\mypy\tem2.py", line 1, in <module>
print (__file__)
NameError: name '__file__' is not defined
This is the bug to be fixed, if reasonably possible.
Both 2.7 and 3.3 set __file__ on regular import (or rather, Idle does not disable this).
>>> import tem2
F:\Python\mypy\tem2.py
I think the first step should be to try this on non-Windows systems.
----------
components: IDLE
messages: 191721
nosy: Todd.Rovito, roger.serwy, terry.reedy
priority: normal
severity: normal
stage: test needed
status: open
title: Idle 2.7: Run Module does not set __file__
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18288>
_______________________________________
More information about the New-bugs-announce
mailing list