@@ -1924,9 +1924,9 @@ def _redirect_output(self, statement: Statement) -> Tuple[bool, RedirectionSaved
19241924 # Create a pipe with read and write sides
19251925 read_fd , write_fd = os .pipe ()
19261926
1927- # Open each side of the pipe and set stdout accordingly
1928- pipe_read = io .open (read_fd , 'r' )
1929- pipe_write = io .open (write_fd , 'w' )
1927+ # Open each side of the pipe
1928+ subproc_stdin = io .open (read_fd , 'r' )
1929+ new_stdout = io .open (write_fd , 'w' )
19301930
19311931 # We want Popen to raise an exception if it fails to open the process. Thus we don't set shell to True.
19321932 try :
@@ -1943,19 +1943,19 @@ def _redirect_output(self, statement: Statement) -> Tuple[bool, RedirectionSaved
19431943 # For any stream that is a StdSim, we will use a pipe so we can capture its output
19441944 proc = \
19451945 subprocess .Popen (statement .pipe_to ,
1946- stdin = pipe_read ,
1946+ stdin = subproc_stdin ,
19471947 stdout = subprocess .PIPE if isinstance (self .stdout , utils .StdSim ) else self .stdout ,
19481948 stderr = subprocess .PIPE if isinstance (sys .stderr , utils .StdSim ) else sys .stderr ,
19491949 creationflags = creationflags ,
19501950 start_new_session = start_new_session )
19511951
19521952 saved_state .redirecting = True
19531953 saved_state .pipe_proc_reader = utils .ProcReader (proc , self .stdout , sys .stderr )
1954- sys .stdout = self .stdout = pipe_write
1954+ sys .stdout = self .stdout = new_stdout
19551955 except Exception as ex :
19561956 self .perror ('Failed to open pipe because - {}' .format (ex ), traceback_war = False )
1957- pipe_read .close ()
1958- pipe_write .close ()
1957+ subproc_stdin .close ()
1958+ new_stdout .close ()
19591959 redir_error = True
19601960
19611961 elif statement .output :
0 commit comments