Skip to content

Commit 08a0fad

Browse files
committed
Make sure that stderr is converted to bytes
remove stderr for a wait() that is not the GitPython wrapper.
1 parent 46201b3 commit 08a0fad

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

git/cmd.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -307,19 +307,28 @@ def __del__(self):
307307
def __getattr__(self, attr):
308308
return getattr(self.proc, attr)
309309

310-
def wait(self, stderr=''):
310+
def wait(self, stderr=b''):
311311
"""Wait for the process and return its status code.
312312
313313
:param stderr: Previously read value of stderr, in case stderr is already closed.
314314
:warn: may deadlock if output or error pipes are used and not handled separately.
315315
: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+
316325
status = self.proc.wait()
317326

318327
def read_all_from_possibly_closed_stream(stream):
319328
try:
320329
return stderr + stream.read()
321330
except ValueError:
322-
return stderr or ''
331+
return stderr or b''
323332

324333
if status != 0:
325334
errstr = read_all_from_possibly_closed_stream(self.proc.stderr)
@@ -678,7 +687,7 @@ def _kill_process(pid):
678687
# strip trailing "\n"
679688
if stderr_value.endswith(b"\n"):
680689
stderr_value = stderr_value[:-1]
681-
status = proc.wait(stderr=stderr_value)
690+
status = proc.wait()
682691
# END stdout handling
683692
finally:
684693
proc.stdout.close()

git/util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,10 +772,10 @@ def done(self):
772772
self.cv.notify_all()
773773
self.cv.release()
774774

775-
def wait(self):
775+
def wait(self, stderr=b''):
776776
self.cv.acquire()
777777
while self.count > 0:
778-
self.cv.wait()
778+
self.cv.wait(strerr=stderr)
779779
self.cv.release()
780780

781781

0 commit comments

Comments
 (0)