[Python-checkins] r81403 - in python/branches/py3k/Lib: subprocess.py test/test_subprocess.py

victor.stinner python-checkins at python.org
Fri May 21 22:13:12 CEST 2010


Author: victor.stinner
Date: Fri May 21 22:13:12 2010
New Revision: 81403

Log:
Issue #8780: Fix a regression introduced by r78946 in subprocess on Windows

Ensure that stdout / stderr is inherited from the parent if stdout=PIPE /
stderr=PIPE is not used.


Modified:
   python/branches/py3k/Lib/subprocess.py
   python/branches/py3k/Lib/test/test_subprocess.py

Modified: python/branches/py3k/Lib/subprocess.py
==============================================================================
--- python/branches/py3k/Lib/subprocess.py	(original)
+++ python/branches/py3k/Lib/subprocess.py	Fri May 21 22:13:12 2010
@@ -843,7 +843,7 @@
             # Process startup details
             if startupinfo is None:
                 startupinfo = STARTUPINFO()
-            if None not in (p2cread, c2pwrite, errwrite):
+            if -1 not in (p2cread, c2pwrite, errwrite):
                 startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
                 startupinfo.hStdInput = p2cread
                 startupinfo.hStdOutput = c2pwrite

Modified: python/branches/py3k/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k/Lib/test/test_subprocess.py	Fri May 21 22:13:12 2010
@@ -535,6 +535,17 @@
             if c.exception.errno != 2:  # ignore "no such file"
                 raise c.exception
 
+    def test_issue8780(self):
+        # Ensure that stdout is inherited from the parent
+        # if stdout=PIPE is not used
+        code = ';'.join((
+            'import subprocess, sys',
+            'retcode = subprocess.call('
+                "[sys.executable, '-c', 'print(\"Hello World!\")'])",
+            'assert retcode == 0'))
+        output = subprocess.check_output([sys.executable, '-c', code])
+        self.assert_(output.startswith(b'Hello World!'), ascii(output))
+
 
 # context manager
 class _SuppressCoreFiles(object):


More information about the Python-checkins mailing list