diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-04-05 18:54:39 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-04-05 18:54:39 (GMT) |
commit | dfe980bb82f52f95d60297e3840a4e6708baa147 (patch) | |
tree | 4efc25687f102af31fc3191e00d1b1d1bb32b58a | |
parent | 0130ad14dd6e9f08590db93cb6a9cb059118dc7c (diff) | |
download | cpython-dfe980bb82f52f95d60297e3840a4e6708baa147.zip cpython-dfe980bb82f52f95d60297e3840a4e6708baa147.tar.gz cpython-dfe980bb82f52f95d60297e3840a4e6708baa147.tar.bz2 |
Issue #8515: Set __file__ when run file in IDLE.
-rw-r--r-- | Lib/idlelib/NEWS.txt | 3 | ||||
-rw-r--r-- | Lib/idlelib/ScriptBinding.py | 12 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
4 files changed, 13 insertions, 6 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index d50abd4..b28e58a 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -1,6 +1,9 @@ What's New in IDLE 3.3? ========================= +- Issue #8515: Set __file__ when run file in IDLE. + Initial patch by Bruce Frederiksen. + - IDLE can be launched as `python -m idlelib` - Issue #14409: IDLE now properly executes commands in the Shell window diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index 18ce965..528adf6 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -150,16 +150,16 @@ class ScriptBinding: dirname = os.path.dirname(filename) # XXX Too often this discards arguments the user just set... interp.runcommand("""if 1: - _filename = %r + __file__ = {filename!r} import sys as _sys from os.path import basename as _basename if (not _sys.argv or - _basename(_sys.argv[0]) != _basename(_filename)): - _sys.argv = [_filename] + _basename(_sys.argv[0]) != _basename(__file__)): + _sys.argv = [__file__] import os as _os - _os.chdir(%r) - del _filename, _sys, _basename, _os - \n""" % (filename, dirname)) + _os.chdir({dirname!r}) + del _sys, _basename, _os + \n""".format(filename=filename, dirname=dirname)) interp.prepend_syspath(filename) # XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still # go to __stderr__. With subprocess, they go to the shell. @@ -333,6 +333,7 @@ Doug Fort John Fouhy Andrew Francis Martin Franklin +Bruce Frederiksen Robin Friedrich Ivan Frohne Matthias Fuchs @@ -19,6 +19,9 @@ Core and Builtins Library ------- +- Issue #8515: Set __file__ when run file in IDLE. + Initial patch by Bruce Frederiksen. + - Issue #14496: Fix wrong name in idlelib/tabbedpages.py. Patch by Popa Claudiu. |