3939PY3 ,
4040bchr ,
4141# just to satisfy flake8 on py3
42- unicode
42+ unicode ,
43+ safe_decode ,
4344)
4445
4546execute_kwargs = ('istream' ,'with_keep_cwd' ,'with_extended_output' ,
@@ -693,12 +694,12 @@ def _kill_process(pid):
693694cmdstr = " " .join (command )
694695
695696def as_text (stdout_value ):
696- return not output_stream and stdout_value . decode ( defenc )or '<OUTPUT_STREAM>'
697+ return not output_stream and safe_decode ( stdout_value )or '<OUTPUT_STREAM>'
697698# end
698699
699700if stderr_value :
700701log .info ("%s -> %d; stdout: '%s'; stderr: '%s'" ,
701- cmdstr ,status ,as_text (stdout_value ),stderr_value . decode ( defenc ))
702+ cmdstr ,status ,as_text (stdout_value ),safe_decode ( stderr_value ))
702703elif stdout_value :
703704log .info ("%s -> %d; stdout: '%s'" ,cmdstr ,status ,as_text (stdout_value ))
704705else :
@@ -712,11 +713,11 @@ def as_text(stdout_value):
712713raise GitCommandError (command ,status ,stderr_value )
713714
714715if isinstance (stdout_value ,bytes )and stdout_as_string :# could also be output_stream
715- stdout_value = stdout_value . decode ( defenc )
716+ stdout_value = safe_decode ( stdout_value )
716717
717718# Allow access to the command's status code
718719if with_extended_output :
719- return (status ,stdout_value ,stderr_value . decode ( defenc ))
720+ return (status ,stdout_value ,safe_decode ( stderr_value ))
720721else :
721722return stdout_value
722723