]> granicus.if.org Git - python/commitdiff
Issue #8780: Fix a regression introduced by r78946 in subprocess on Windows
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 21 May 2010 20:13:12 +0000 (20:13 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 21 May 2010 20:13:12 +0000 (20:13 +0000)
Ensure that stdout / stderr is inherited from the parent if stdout=PIPE /
stderr=PIPE is not used.

Lib/subprocess.py
Lib/test/test_subprocess.py

index adbee0b51dbd00a74372032fad748b869d080942..ad6fd1f7a5a8da7496f603d6aa06a0810e5c6881 100644 (file)
@@ -843,7 +843,7 @@ class Popen(object):
             # 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
index 96c8ebfcfbd35aeaf34fd5f9efae28d56238de64..0dd5da439955bdfa65f0d76d7e592a82c5cf1dd9 100644 (file)
@@ -535,6 +535,17 @@ class ProcessTestCase(BaseTestCase):
             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):