summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/subprocess.py2
-rw-r--r--Lib/test/test_subprocess.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index adbee0b..ad6fd1f 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -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
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 96c8ebf..0dd5da4 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -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):