File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -87,14 +87,11 @@ def main():
8787            infile  =  sys .stdin 
8888        else :
8989            infile  =  open (options .infile , encoding = 'utf-8' )
90-         try :
91-             if  options .json_lines :
92-                 objs  =  (json .loads (line ) for  line  in  infile )
93-             else :
94-                 objs  =  (json .load (infile ),)
95-         finally :
96-             if  infile  is  not sys .stdin :
97-                 infile .close ()
90+ 
91+         if  options .json_lines :
92+             objs  =  (json .loads (line ) for  line  in  infile )
93+         else :
94+             objs  =  (json .load (infile ),)
9895
9996        if  options .outfile  is  None :
10097            outfile  =  sys .stdout 
@@ -111,6 +108,8 @@ def main():
111108                for  obj  in  objs :
112109                    json .dump (obj , outfile , ** dump_args )
113110                    outfile .write ('\n ' )
111+         if  infile  is  not sys .stdin :
112+             infile .close ()
114113    except  ValueError  as  e :
115114        raise  SystemExit (e )
116115
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments