@@ -119,13 +119,14 @@ def run_clang_format_diff(args, file_name):
119119 raise DiffError (str (exc ))
120120 proc_stdout = proc .stdout
121121 proc_stderr = proc .stderr
122- if sys .version_info [0 ] < 3 :
123- # make the pipes compatible with Python 3,
124- # reading lines should output unicode
125- encoding = 'utf-8'
126- proc_stdout = codecs .getreader (encoding )(proc_stdout )
127- proc_stderr = codecs .getreader (encoding )(proc_stderr )
128- # hopefully the stderr pipe won't get full and block the process
122+ if sys .version_info [0 ] == 3 :
123+ proc_stdout = proc_stdout .detach ()
124+ proc_stderr = proc_stderr .detach ()
125+ # make the pipes compatible with Python 3,
126+ # reading lines should output unicode
127+ encoding = 'utf-8'
128+ proc_stdout = codecs .getreader (encoding )(proc_stdout )
129+ proc_stderr = codecs .getreader (encoding )(proc_stderr )
129130 outs = list (proc_stdout .readlines ())
130131 errs = list (proc_stderr .readlines ())
131132 proc .wait ()
@@ -330,8 +331,8 @@ def main():
330331 if not args .quiet :
331332 print_diff (outs , use_color = colored_stdout )
332333 for line in outs :
333- patch_file .write (line )
334- patch_file .write ('\n ' )
334+ patch_file .write (line . encode ( 'utf-8' ) )
335+ patch_file .write ('\n ' . encode ( 'utf-8' ) )
335336 if retcode == ExitStatus .SUCCESS :
336337 retcode = ExitStatus .DIFF
337338
0 commit comments