diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2002-07-28 03:35:31 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2002-07-28 03:35:31 (GMT) |
commit | d694c1faf9314c9c531db59d24f90223cf720583 (patch) | |
tree | b60e25eda897be97f11dc69893e65171957bd7de | |
parent | 139bccb2f017622efd6c31f72aab97356a22090b (diff) | |
download | cpython-d694c1faf9314c9c531db59d24f90223cf720583.zip cpython-d694c1faf9314c9c531db59d24f90223cf720583.tar.gz cpython-d694c1faf9314c9c531db59d24f90223cf720583.tar.bz2 |
Reset the Python execution server environment to its initial value prior
to executing Run/F5 from an EditorWindow.
M ScriptBinding.py : add call to clear_the_environment()
M run.py : implemented Executive.clear_the_environment()
-rw-r--r-- | Lib/idlelib/ScriptBinding.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/run.py | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index 68f9cd7..6d4c652 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -144,10 +144,11 @@ class ScriptBinding: filename = self.getfilename() if not filename: return - flist = self.editwin.flist shell = flist.open_shell() interp = shell.interp + # clear the subprocess environment before every Run/F5 invocation + interp.rpcclt.remotecall("exec", "clear_the_environment", (), {}) # XXX Too often this discards arguments the user just set... interp.runcommand("""if 1: _filename = %s @@ -155,6 +156,7 @@ class ScriptBinding: from os.path import basename as _basename if (not _sys.argv or _basename(_sys.argv[0]) != _basename(_filename)): + # XXX 25 July 2002 KBK should this be sys.argv not _sys.argv? _sys.argv = [_filename] del _filename, _sys, _basename \n""" % `filename`) diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 5db652e..cc3edf1 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -1,6 +1,7 @@ import sys import time import socket +import __main__ import rpc def main(): @@ -55,11 +56,18 @@ class Executive: def __init__(self, rpchandler): self.rpchandler = rpchandler - import __main__ - self.locals = __main__.__dict__ + self.base_env_keys = __main__.__dict__.keys() def runcode(self, code): - exec code in self.locals + exec code in __main__.__dict__ + + def clear_the_environment(self): + global __main__ + env = __main__.__dict__ + for key in env.keys(): + if key not in self.base_env_keys: + del env[key] + env['__doc__'] = None def start_the_debugger(self, gui_adap_oid): import RemoteDebugger |