39
39
PY3 ,
40
40
bchr ,
41
41
# just to satisfy flake8 on py3
42
- unicode
42
+ unicode ,
43
+ safe_decode ,
43
44
)
44
45
45
46
execute_kwargs = ('istream' , 'with_keep_cwd' , 'with_extended_output' ,
@@ -693,12 +694,12 @@ def _kill_process(pid):
693
694
cmdstr = " " .join (command )
694
695
695
696
def 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>'
697
698
# end
698
699
699
700
if stderr_value :
700
701
log .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 ))
702
703
elif stdout_value :
703
704
log .info ("%s -> %d; stdout: '%s'" , cmdstr , status , as_text (stdout_value ))
704
705
else :
@@ -712,11 +713,11 @@ def as_text(stdout_value):
712
713
raise GitCommandError (command , status , stderr_value )
713
714
714
715
if 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 )
716
717
717
718
# Allow access to the command's status code
718
719
if with_extended_output :
719
- return (status , stdout_value , stderr_value . decode ( defenc ))
720
+ return (status , stdout_value , safe_decode ( stderr_value ))
720
721
else :
721
722
return stdout_value
722
723
0 commit comments