summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
authorBarry Scott <barry@barrys-emacs.org>2016-05-30 15:49:40 +0100
committerBarry Scott <barry@barrys-emacs.org>2016-05-30 15:49:40 +0100
commit08a0fad2c9dcdfe0bbc980b8cd260b4be5582381 (patch)
treebf17683c442cff2ff4e4a61a0a069673940cec55 /git/cmd.py
parent46201b346fec29f9cb740728a3c20266094d58b2 (diff)
downloadgitpython-08a0fad2c9dcdfe0bbc980b8cd260b4be5582381.tar.gz
Make sure that stderr is converted to bytes
remove stderr for a wait() that is not the GitPython wrapper.
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 821bf299..e3b39bda 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -307,19 +307,28 @@ class Git(LazyMixin):
def __getattr__(self, attr):
return getattr(self.proc, attr)
- def wait(self, stderr=''):
+ def wait(self, stderr=b''):
"""Wait for the process and return its status code.
:param stderr: Previously read value of stderr, in case stderr is already closed.
:warn: may deadlock if output or error pipes are used and not handled separately.
:raise GitCommandError: if the return status is not 0"""
+
+ # stderr must be a bytes object as it will
+ # combined with more data from the process and
+ # decoded by the caller
+ if stderr is None:
+ stderr = b''
+ elif type(stderr) == unicode:
+ stderr = stderr.encode(defenc)
+
status = self.proc.wait()
def read_all_from_possibly_closed_stream(stream):
try:
return stderr + stream.read()
except ValueError:
- return stderr or ''
+ return stderr or b''
if status != 0:
errstr = read_all_from_possibly_closed_stream(self.proc.stderr)
@@ -678,7 +687,7 @@ class Git(LazyMixin):
# strip trailing "\n"
if stderr_value.endswith(b"\n"):
stderr_value = stderr_value[:-1]
- status = proc.wait(stderr=stderr_value)
+ status = proc.wait()
# END stdout handling
finally:
proc.stdout.close()