@@ -307,19 +307,28 @@ def __del__(self):
307
307
def __getattr__ (self , attr ):
308
308
return getattr (self .proc , attr )
309
309
310
- def wait (self , stderr = '' ):
310
+ def wait (self , stderr = b '' ):
311
311
"""Wait for the process and return its status code.
312
312
313
313
:param stderr: Previously read value of stderr, in case stderr is already closed.
314
314
:warn: may deadlock if output or error pipes are used and not handled separately.
315
315
:raise GitCommandError: if the return status is not 0"""
316
+
317
+ # stderr must be a bytes object as it will
318
+ # combined with more data from the process and
319
+ # decoded by the caller
320
+ if stderr is None :
321
+ stderr = b''
322
+ elif type (stderr ) == unicode :
323
+ stderr = stderr .encode (defenc )
324
+
316
325
status = self .proc .wait ()
317
326
318
327
def read_all_from_possibly_closed_stream (stream ):
319
328
try :
320
329
return stderr + stream .read ()
321
330
except ValueError :
322
- return stderr or ''
331
+ return stderr or b ''
323
332
324
333
if status != 0 :
325
334
errstr = read_all_from_possibly_closed_stream (self .proc .stderr )
@@ -678,7 +687,7 @@ def _kill_process(pid):
678
687
# strip trailing "\n"
679
688
if stderr_value .endswith (b"\n " ):
680
689
stderr_value = stderr_value [:- 1 ]
681
- status = proc .wait (stderr = stderr_value )
690
+ status = proc .wait ()
682
691
# END stdout handling
683
692
finally :
684
693
proc .stdout .close ()
0 commit comments