This commit is contained in:
David Sanders 2020-10-04 23:00:35 -07:00 коммит произвёл GitHub
Родитель 4ccc9e4205
Коммит c075d14920
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -119,13 +119,14 @@ def run_clang_format_diff(args, file_name):
raise DiffError(str(exc)) raise DiffError(str(exc))
proc_stdout = proc.stdout proc_stdout = proc.stdout
proc_stderr = proc.stderr proc_stderr = proc.stderr
if sys.version_info[0] < 3: if sys.version_info[0] == 3:
# make the pipes compatible with Python 3, proc_stdout = proc_stdout.detach()
# reading lines should output unicode proc_stderr = proc_stderr.detach()
encoding = 'utf-8' # make the pipes compatible with Python 3,
proc_stdout = codecs.getreader(encoding)(proc_stdout) # reading lines should output unicode
proc_stderr = codecs.getreader(encoding)(proc_stderr) encoding = 'utf-8'
# hopefully the stderr pipe won't get full and block the process proc_stdout = codecs.getreader(encoding)(proc_stdout)
proc_stderr = codecs.getreader(encoding)(proc_stderr)
outs = list(proc_stdout.readlines()) outs = list(proc_stdout.readlines())
errs = list(proc_stderr.readlines()) errs = list(proc_stderr.readlines())
proc.wait() proc.wait()
@ -330,8 +331,8 @@ def main():
if not args.quiet: if not args.quiet:
print_diff(outs, use_color=colored_stdout) print_diff(outs, use_color=colored_stdout)
for line in outs: for line in outs:
patch_file.write(line) patch_file.write(line.encode('utf-8'))
patch_file.write('\n') patch_file.write('\n'.encode('utf-8'))
if retcode == ExitStatus.SUCCESS: if retcode == ExitStatus.SUCCESS:
retcode = ExitStatus.DIFF retcode = ExitStatus.DIFF