[Python-checkins] python/dist/src/Lib subprocess.py,1.7,1.8

astrand at users.sourceforge.net astrand at users.sourceforge.net
Sun Nov 7 15:30:38 CET 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4566/Lib
Modified Files:
	subprocess.py 
Log Message:
When using shell=True on Windows, don't display a shell window by default. Fixes #1057061.
Index: subprocess.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- subprocess.py	17 Oct 2004 16:36:53 -0000	1.7
+++ subprocess.py	7 Nov 2004 14:30:34 -0000	1.8
@@ -372,11 +372,11 @@
 STD_OUTPUT_HANDLE, STD_ERROR_HANDLE
 from win32api import GetCurrentProcess, DuplicateHandle, \
 GetModuleFileName, GetVersion
- from win32con import DUPLICATE_SAME_ACCESS
+ from win32con import DUPLICATE_SAME_ACCESS, SW_HIDE
 from win32pipe import CreatePipe
 from win32process import CreateProcess, STARTUPINFO, \
 GetExitCodeProcess, STARTF_USESTDHANDLES, \
- CREATE_NEW_CONSOLE
+ STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE
 from win32event import WaitForSingleObject, INFINITE, WAIT_OBJECT_0
 else:
 from _subprocess import *
@@ -673,7 +673,19 @@
 if not isinstance(args, types.StringTypes):
 args = list2cmdline(args)
 
+ # Process startup details
+ default_startupinfo = STARTUPINFO()
+ if startupinfo == None:
+ startupinfo = default_startupinfo
+ if not None in (p2cread, c2pwrite, errwrite):
+ startupinfo.dwFlags |= STARTF_USESTDHANDLES
+ startupinfo.hStdInput = p2cread
+ startupinfo.hStdOutput = c2pwrite
+ startupinfo.hStdError = errwrite
+
 if shell:
+ default_startupinfo.dwFlags |= STARTF_USESHOWWINDOW
+ default_startupinfo.wShowWindow = SW_HIDE
 comspec = os.environ.get("COMSPEC", "cmd.exe")
 args = comspec + " /c " + args
 if (GetVersion() >= 0x80000000L or
@@ -692,15 +704,6 @@
 # kill children.
 creationflags |= CREATE_NEW_CONSOLE
 
- # Process startup details
- if startupinfo == None:
- startupinfo = STARTUPINFO()
- if not None in (p2cread, c2pwrite, errwrite):
- startupinfo.dwFlags |= STARTF_USESTDHANDLES
- startupinfo.hStdInput = p2cread
- startupinfo.hStdOutput = c2pwrite
- startupinfo.hStdError = errwrite
-
 # Start the process
 try:
 hp, ht, pid, tid = CreateProcess(executable, args,


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /