@@ -350,24 +350,31 @@ def _iter_from_process_or_stream(cls, odb, proc_or_stream):
350350 :param proc: git-rev-list process instance - one sha per line
351351 :return: iterator returning Commit objects"""
352352 stream = proc_or_stream
353+ close_std_err = False
353354 if not hasattr (stream ,'readline' ):
354355 stream = proc_or_stream .stdout
356+ close_std_err = True
355357
356358 readline = stream .readline
357- while True :
358- line = readline ()
359- if not line :
360- break
361- hexsha = line .strip ()
362- if len (hexsha ) > 40 :
363- # split additional information, as returned by bisect for instance
364- hexsha , rest = line .split (None , 1 )
365- # END handle extra info
366-
367- assert len (hexsha ) == 40 , "Invalid line: %s" % hexsha
368- yield cls (odb , hex_to_bin (hexsha ))
369- # END for each line in stream
370-
359+ try :
360+ while True :
361+ line = readline ()
362+ if not line :
363+ break
364+ hexsha = line .strip ()
365+ if len (hexsha ) > 40 :
366+ # split additional information, as returned by bisect for instance
367+ hexsha , rest = line .split (None , 1 )
368+ # END handle extra info
369+
370+ assert len (hexsha ) == 40 , "Invalid line: %s" % hexsha
371+ yield cls (odb , hex_to_bin (hexsha ))
372+ # END for each line in stream
373+ finally :
374+ stream .close ()
375+ if close_std_err :
376+ proc_or_stream .stderr .close ()
377+
371378 #{ Serializable Implementation
372379
373380 def _serialize (self , stream ):
0 commit comments