@@ -772,6 +772,7 @@ def _kill_process(pid):
772772status = 0
773773stdout_value = b''
774774stderr_value = b''
775+ newline = "\n " if universal_newlines else b"\n "
775776try :
776777if output_stream is None :
777778if kill_after_timeout :
@@ -783,9 +784,9 @@ def _kill_process(pid):
783784stderr_value = ('Timeout: the command "%s" did not complete in %d '
784785'secs.' % (" " .join (command ),kill_after_timeout )).encode (defenc )
785786# strip trailing "\n"
786- if stdout_value .endswith (b" \n " ):
787+ if stdout_value .endswith (newline ):
787788stdout_value = stdout_value [:- 1 ]
788- if stderr_value .endswith (b" \n " ):
789+ if stderr_value .endswith (newline ):
789790stderr_value = stderr_value [:- 1 ]
790791status = proc .returncode
791792else :
@@ -794,7 +795,7 @@ def _kill_process(pid):
794795stdout_value = proc .stdout .read ()
795796stderr_value = proc .stderr .read ()
796797# strip trailing "\n"
797- if stderr_value .endswith (b" \n " ):
798+ if stderr_value .endswith (newline ):
798799stderr_value = stderr_value [:- 1 ]
799800status = proc .wait ()
800801# END stdout handling