summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2016-02-13 18:02:37 +0100
committerSebastian Thiel <byronimo@gmail.com>2016-02-13 18:03:14 +0100
commitd2f6fef3c887719a250c78c22cba723b2200df1b (patch)
treec42c49d25ed64502983f2a35a942f8d23aaa4c15 /git
parentad3931357e5bb01941b50482b4b53934c0b715e3 (diff)
downloadgitpython-d2f6fef3c887719a250c78c22cba723b2200df1b.tar.gz
fix(cmd): safely read from stderr
Fixes #383
Diffstat (limited to 'git')
-rw-r--r--git/cmd.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 3fa24fff..d2794c02 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -315,8 +315,16 @@ class Git(LazyMixin):
:warn: may deadlock if output or error pipes are used and not handled separately.
:raise GitCommandError: if the return status is not 0"""
status = self.proc.wait()
+
+ def read_all_from_possibly_closed_stream(stream):
+ try:
+ return stream.read()
+ except ValueError:
+ return ''
+
if status != 0:
- raise GitCommandError(self.args, status, self.proc.stderr.read())
+ errstr = read_all_from_possibly_closed_stream(self.proc.stderr.read)
+ raise GitCommandError(self.args, status, errstr)
# END status handling
return status
# END auto interrupt