diff --git a/git/cmd.py b/git/cmd.py index acea40c5a..836aafffb 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -772,6 +772,7 @@ def _kill_process(pid): status = 0 stdout_value = b'' stderr_value = b'' + newline = "\n" if universal_newlines else b"\n" try: if output_stream is None: if kill_after_timeout: @@ -783,9 +784,9 @@ def _kill_process(pid): stderr_value = ('Timeout: the command "%s" did not complete in %d ' 'secs.' % (" ".join(command), kill_after_timeout)).encode(defenc) # strip trailing "\n" - if stdout_value.endswith(b"\n"): + if stdout_value.endswith(newline): stdout_value = stdout_value[:-1] - if stderr_value.endswith(b"\n"): + if stderr_value.endswith(newline): stderr_value = stderr_value[:-1] status = proc.returncode else: @@ -794,7 +795,7 @@ def _kill_process(pid): stdout_value = proc.stdout.read() stderr_value = proc.stderr.read() # strip trailing "\n" - if stderr_value.endswith(b"\n"): + if stderr_value.endswith(newline): stderr_value = stderr_value[:-1] status = proc.wait() # END stdout handling