Skip to content

Fix TypeError in git.execute(..., output_stream=file) #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix TypeError in git.execute(..., output_stream=file)
This fixes #619 - raise GitCommandError(not TypeError) when output_stream is set
in git.execute
  • Loading branch information
Dmitry Nikulin committed Jul 24, 2018
commit 2011c5d33c6c49c7d935095e33892ac58c99d902
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably the only way to do this properly, even though it seems funky. Ideally stdout_value should be the value read, but in this case, it will always be an empty string as read() is called right after stream_copy(...).
However, looking at it, the whole implementations seems to have gotten somewhat convoluted over the years, so it's probably alright after all.

stderr_value = proc.stderr.read()
# strip trailing "\n"
if stderr_value.endswith(b"\n"):
Expand Down