Ticket #5726: dont-open-console-window-v2.diff
| File dont-open-console-window-v2.diff, 3.6 KB (added by alecu, 11 months ago) |
|---|
-
twisted/internet/_dumbwin32proc.py
=== modified file 'twisted/internet/_dumbwin32proc.py'
172 172 cmdline = quoteArguments(args) 173 173 # TODO: error detection here. See #2787 and #4184. 174 174 def doCreate(): 175 flags = win32con.CREATE_NO_WINDOW 175 176 self.hProcess, self.hThread, self.pid, dwTid = win32process.CreateProcess( 176 command, cmdline, None, None, 1, 0, env, path, StartupInfo)177 command, cmdline, None, None, 1, flags, env, path, StartupInfo) 177 178 try: 178 179 try: 179 180 doCreate() -
twisted/test/test_process.py
=== modified file 'twisted/test/test_process.py'
27 27 from twisted.python.log import msg 28 28 from twisted.internet import reactor, protocol, error, interfaces, defer 29 29 from twisted.trial import unittest 30 from twisted.python import util, runtime, procutils30 from twisted.python import filepath, util, runtime, procutils 31 31 from twisted.python.compat import set 32 32 33 33 … … 2350 2350 2351 2351 2352 2352 2353 class Win32CreateProcessFlagsTest(unittest.TestCase): 2354 """ 2355 Check the flags passed to CreateProcess. 2356 """ 2357 2358 @defer.inlineCallbacks 2359 def test_flags(self): 2360 """ 2361 Verify that the flags passed to win32process.CreateProcess() prevent a 2362 new console window from being created. See bug #5726 for a script to 2363 test this interactively. 2364 """ 2365 from twisted.internet import _dumbwin32proc 2366 flags = [] 2367 real_CreateProcess = _dumbwin32proc.win32process.CreateProcess 2368 2369 def fake_createprocess(_appName, _commandLine, _processAttributes, 2370 _threadAttributes, _bInheritHandles, creationFlags, 2371 _newEnvironment, _currentDirectory, startupinfo): 2372 """Store the creationFlags for later comparing.""" 2373 flags.append(creationFlags) 2374 return real_CreateProcess(_appName, _commandLine, 2375 _processAttributes, _threadAttributes, 2376 _bInheritHandles, creationFlags, _newEnvironment, 2377 _currentDirectory, startupinfo) 2378 2379 self.patch(_dumbwin32proc.win32process, "CreateProcess", 2380 fake_createprocess) 2381 exe = sys.executable 2382 scriptPath = filepath.FilePath(__file__).sibling("process_cmdline.py") 2383 2384 d = defer.Deferred() 2385 processProto = TrivialProcessProtocol(d) 2386 comspec = str(os.environ["COMSPEC"]) 2387 cmd = [comspec, "/c", exe, scriptPath.path] 2388 _dumbwin32proc.Process(reactor, processProto, None, cmd, {}, None) 2389 yield d 2390 self.assertEqual(flags, 2391 [_dumbwin32proc.win32process.CREATE_NO_WINDOW]) 2392 2393 2394 2353 2395 class UtilTestCase(unittest.TestCase): 2354 2396 """ 2355 2397 Tests for process-related helper functions (currently only … … 2553 2595 Win32ProcessTestCase.skip = skipMessage 2554 2596 TestTwoProcessesNonPosix.skip = skipMessage 2555 2597 Dumbwin32procPidTest.skip = skipMessage 2598 Win32CreateProcessFlagsTest.skip = skipMessage 2556 2599 Win32UnicodeEnvironmentTest.skip = skipMessage 2557 2600 2558 2601 if not interfaces.IReactorProcess(reactor, None): -
twisted/topfiles/5726.bugfix
=== added file 'twisted/topfiles/5726.bugfix'
1 spawnProcess no longer opens an unwanted console on Windows
