This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年06月23日 19:10 by terry.reedy, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg191721 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2013年06月23日 19:10 | |
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. |
|||
| msg191723 - (view) | Author: Francis MB (francismb) * | Date: 2013年06月23日 19:40 | |
On Debian: * Command line 2.7.3 ~/Prog/mypy$ python2.7 tem2.py tem2.py ~/Prog/mypy$ python2.7 -m tem2 /home/ci/Prog/mypy/tem2.py * IDLE 2.7.3 >>> print(__file__) Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> print(__file__) NameError: name '__file__' is not defined >>> >>> import tem2 tem2.pyc >>> |
|||
| msg191725 - (view) | Author: Francis MB (francismb) * | Date: 2013年06月23日 19:44 | |
From Idle editor window (F5): >>> Traceback (most recent call last): File "/home/ci/Prog/mypy/tem2.py", line 1, in <module> print(__file__) NameError: name '__file__' is not defined >>> |
|||
| msg191745 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2013年06月24日 05:52 | |
Thanks, not specifically Windows then. |
|||
| msg192086 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2013年06月30日 21:24 | |
See issue8515. The patch was not applied to 2.7. |
|||
| msg192091 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2013年06月30日 23:09 | |
Thanks Roger, problem fixed. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:47 | admin | set | github: 62488 |
| 2013年06月30日 23:09:39 | terry.reedy | set | status: open -> closed messages: + msg192091 dependencies: + idle "Run Module" (F5) does not set __file__ variable resolution: duplicate stage: test needed -> resolved |
| 2013年06月30日 21:24:03 | roger.serwy | set | messages: + msg192086 |
| 2013年06月24日 05:52:13 | terry.reedy | set | messages: + msg191745 |
| 2013年06月23日 19:44:37 | francismb | set | messages: + msg191725 |
| 2013年06月23日 19:40:47 | francismb | set | nosy:
+ francismb messages: + msg191723 |
| 2013年06月23日 19:10:49 | terry.reedy | create | |