File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -601,13 +601,17 @@ def main():
601601        with  open (args [0 ], 'rb' ) as  f :
602602            func (f , sys .stdout .buffer )
603603    else :
604-         # Read all input data at once when reading from stdin 
605-         # This allows proper handling of EOF (Ctrl+D) 
606-         input_data  =  sys .stdin .buffer .read ()
607-         if  input_data :
608-             import  io 
609-             input_buffer  =  io .BytesIO (input_data )
610-             func (input_buffer , sys .stdout .buffer )
604+         if  sys .stdin .isatty ():
605+             # gh-gh-138775: read input data at once when reading from stdin 
606+             # This allows proper handling of EOF (Ctrl+D) 
607+             input_data  =  sys .stdin .buffer .read ()
608+             if  input_data :
609+                 import  io 
610+                 input_buffer  =  io .BytesIO (input_data )
611+                 func (input_buffer , sys .stdout .buffer )
612+         else :
613+             # keep the old behaviour for non-interactive input 
614+             func (sys .stdin .buffer , sys .stdout .buffer )
611615
612616
613617if  __name__  ==  '__main__' :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments