From 5a7ed7593d660107c9a9b2fb5ef08d6dde39fa60 Mon Sep 17 00:00:00 2001 From: Dmitry Nikulin Date: Tue, 24 Jul 2018 23:43:35 +0300 Subject: [PATCH 1/2] Add test that raises TypeError in git.execute(..., output_stream=file) --- git/test/test_git.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git/test/test_git.py b/git/test/test_git.py index c6180f7c9..cc931239f 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -7,6 +7,7 @@ import os import subprocess import sys +from tempfile import TemporaryFile from git import ( Git, @@ -108,6 +109,11 @@ def test_it_ignores_false_kwargs(self, git): self.git.version(pass_this_kwarg=False) assert_true("pass_this_kwarg" not in git.call_args[1]) + @raises(GitCommandError) + def test_it_raises_proper_exception_with_output_stream(self): + tmp_file = TemporaryFile() + self.git.checkout('non-existent-branch', output_stream=tmp_file) + def test_it_accepts_environment_variables(self): filename = fixture_path("ls_tree_empty") with open(filename, 'r') as fh: From 2011c5d33c6c49c7d935095e33892ac58c99d902 Mon Sep 17 00:00:00 2001 From: Dmitry Nikulin Date: Tue, 24 Jul 2018 23:43:48 +0300 Subject: [PATCH 2/2] Fix TypeError in git.execute(..., output_stream=file) This fixes #619 - raise GitCommandError(not TypeError) when output_stream is set in git.execute --- git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/cmd.py b/git/cmd.py index 54537a41d..300284874 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -794,7 +794,7 @@ def _kill_process(pid): else: max_chunk_size = max_chunk_size if max_chunk_size and max_chunk_size > 0 else io.DEFAULT_BUFFER_SIZE stream_copy(proc.stdout, output_stream, max_chunk_size) - stdout_value = output_stream + stdout_value = proc.stdout.read() stderr_value = proc.stderr.read() # strip trailing "\n" if stderr_value.endswith(b"\n"):