mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
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()
This commit is contained in:
parent
139bccb2f0
commit
d694c1faf9
2 changed files with 14 additions and 4 deletions
|
@ -144,10 +144,11 @@ class ScriptBinding:
|
||||||
filename = self.getfilename()
|
filename = self.getfilename()
|
||||||
if not filename:
|
if not filename:
|
||||||
return
|
return
|
||||||
|
|
||||||
flist = self.editwin.flist
|
flist = self.editwin.flist
|
||||||
shell = flist.open_shell()
|
shell = flist.open_shell()
|
||||||
interp = shell.interp
|
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...
|
# XXX Too often this discards arguments the user just set...
|
||||||
interp.runcommand("""if 1:
|
interp.runcommand("""if 1:
|
||||||
_filename = %s
|
_filename = %s
|
||||||
|
@ -155,6 +156,7 @@ class ScriptBinding:
|
||||||
from os.path import basename as _basename
|
from os.path import basename as _basename
|
||||||
if (not _sys.argv or
|
if (not _sys.argv or
|
||||||
_basename(_sys.argv[0]) != _basename(_filename)):
|
_basename(_sys.argv[0]) != _basename(_filename)):
|
||||||
|
# XXX 25 July 2002 KBK should this be sys.argv not _sys.argv?
|
||||||
_sys.argv = [_filename]
|
_sys.argv = [_filename]
|
||||||
del _filename, _sys, _basename
|
del _filename, _sys, _basename
|
||||||
\n""" % `filename`)
|
\n""" % `filename`)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
|
import __main__
|
||||||
import rpc
|
import rpc
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -55,11 +56,18 @@ class Executive:
|
||||||
|
|
||||||
def __init__(self, rpchandler):
|
def __init__(self, rpchandler):
|
||||||
self.rpchandler = rpchandler
|
self.rpchandler = rpchandler
|
||||||
import __main__
|
self.base_env_keys = __main__.__dict__.keys()
|
||||||
self.locals = __main__.__dict__
|
|
||||||
|
|
||||||
def runcode(self, code):
|
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):
|
def start_the_debugger(self, gui_adap_oid):
|
||||||
import RemoteDebugger
|
import RemoteDebugger
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue