зеркало из https://github.com/electron/electron.git
fix: python3 compatibility (#25762)
This commit is contained in:
Родитель
4ccc9e4205
Коммит
c075d14920
|
@ -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
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче