### Eclipse Workspace Patch 1.0 #P jython-trunk Index: src/shell/jython.bat =================================================================== --- src/shell/jython.bat (revision 7191) +++ src/shell/jython.bat (working copy) @@ -24,9 +24,12 @@ rem ----- Verify and set required environment variables ----------------------- +rem make sure to clear the internal variables, to prevent leaking into subprocess calls set _JAVA_CMD=java if defined JAVA_HOME set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" -if defined JYTHON_OPTS set _JYTHON_OPTS="%JYTHON_OPTS:"=%" +set _JYTHON_OPTS= +if defined JYTHON_OPTS set _JYTHON_OPTS="%JYTHON_OPTS:"=%" +set _JYTHON_HOME= if defined JYTHON_HOME set _JYTHON_HOME="%JYTHON_HOME:"=%" if defined _JYTHON_HOME goto gotHome Index: Lib/test/test_bat_jy.py =================================================================== --- Lib/test/test_bat_jy.py (revision 7189) +++ Lib/test/test_bat_jy.py (working copy) @@ -48,7 +48,7 @@ return self.process.getErrorStream() class StarterProcess: - def writeStarter(self, args, javaHome, jythonHome, jythonOpts): + def writeStarter(self, args, javaHome, jythonHome, jythonOpts, internals=False): (starter, starterPath) = tempfile.mkstemp(suffix='.bat', prefix='starter', text=True) starter.close() outfilePath = starterPath[:-4] + '.out' @@ -60,6 +60,9 @@ starter.write('set JYTHON_HOME=%s\n' % jythonHome) if jythonOpts: starter.write('set JYTHON_OPTS=%s\n' % jythonOpts) + if internals: + starter.write('set _JYTHON_OPTS=leaking_internals\n') + starter.write('set _JYTHON_HOME=c:/leaking/internals\n') starter.write(self.buildCommand(args, outfilePath)) return (starterPath, outfilePath) finally: @@ -92,9 +95,9 @@ except IllegalThreadStateException: return True - def run(self, args, javaHome, jythonHome, jythonOpts): + def run(self, args, javaHome, jythonHome, jythonOpts, internals=False): ''' creates a start script, executes it and captures the output ''' - (starterPath, outfilePath) = self.writeStarter(args, javaHome, jythonHome, jythonOpts) + (starterPath, outfilePath) = self.writeStarter(args, javaHome, jythonHome, jythonOpts, internals) try: process = Runtime.getRuntime().exec(starterPath) stdoutMonitor = StdoutMonitor(process) @@ -130,7 +133,7 @@ home = ex[:-11] # \jython.bat return home - def assertOutput(self, flags=None, javaHome=None, jythonHome=None, jythonOpts=None): + def assertOutput(self, flags=None, javaHome=None, jythonHome=None, jythonOpts=None, internals=False): args = [self.quote(sys.executable), '--print'] memory = None stack = None @@ -161,7 +164,7 @@ jythonArgs = jythonArgs.replace('%%', '%') # workaround two .bat files args.append(flag) process = StarterProcess() - out = process.run(args, javaHome, jythonHome, jythonOpts) + out = process.run(args, javaHome, jythonHome, jythonOpts, internals) self.assertNotEquals('', out) homeIdx = out.find('-Dpython.home=') java = 'java' @@ -256,7 +259,11 @@ def test_multiple(self): self.assertOutput(jythonOpts='some arbitrary options') - + +class InternalsTest(BaseTest): + def test_no_leaks(self): + self.assertOutput(internals=True) + class JavaOptsTest(BaseTest): def test_memory(self): self.assertOutput(['-J-Xmx321m']) @@ -387,6 +394,7 @@ JavaHomeTest, JythonHomeTest, JythonOptsTest, + InternalsTest, JavaOptsTest, ArgsTest, DoubleDashTest,