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