mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									f978facc0e
								
							
						
					
					
						commit
						b369358ee4
					
				
					 2 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
					@ -843,7 +843,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
 | 
				
			||||||
            # Process startup details
 | 
					            # Process startup details
 | 
				
			||||||
            if startupinfo is None:
 | 
					            if startupinfo is None:
 | 
				
			||||||
                startupinfo = STARTUPINFO()
 | 
					                startupinfo = STARTUPINFO()
 | 
				
			||||||
            if None not in (p2cread, c2pwrite, errwrite):
 | 
					            if -1 not in (p2cread, c2pwrite, errwrite):
 | 
				
			||||||
                startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
 | 
					                startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
 | 
				
			||||||
                startupinfo.hStdInput = p2cread
 | 
					                startupinfo.hStdInput = p2cread
 | 
				
			||||||
                startupinfo.hStdOutput = c2pwrite
 | 
					                startupinfo.hStdOutput = c2pwrite
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -535,6 +535,17 @@ def test_leaking_fds_on_error(self):
 | 
				
			||||||
            if c.exception.errno != 2:  # ignore "no such file"
 | 
					            if c.exception.errno != 2:  # ignore "no such file"
 | 
				
			||||||
                raise c.exception
 | 
					                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
 | 
					# context manager
 | 
				
			||||||
class _SuppressCoreFiles(object):
 | 
					class _SuppressCoreFiles(object):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue