From 735d709e84951aeb2879876373133931da297a95 Mon Sep 17 00:00:00 2001 From: Chiel ten Brinke Date: Thu, 29 Oct 2015 12:22:48 +0100 Subject: [PATCH] Fix python3 support. --- plugin/autoformat.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/autoformat.vim b/plugin/autoformat.vim index 1875aa3..d958782 100644 --- a/plugin/autoformat.vim +++ b/plugin/autoformat.vim @@ -191,6 +191,8 @@ if stderrdata: print('Failing config: {} '.format(repr(formatprg), stderrdata)) vim.command('return 0') else: + stdoutdata = stdoutdata.decode('utf-8') + # Often shell commands will append a newline at the end of their output. # It is not entirely clear when and why that happens. # However, extra newlines are almost never required, while there are linters that complain @@ -198,12 +200,10 @@ else: if stdoutdata[-1] == os.linesep: stdoutdata = stdoutdata[:-1] - stdoutdata = stdoutdata.decode('utf-8') - # It is not certain what kind of line endings are being used by the format program. # Therefore we simply split on all possible eol characters. lines = [stdoutdata] - for eol in [b'\r\n', b'\r', b'\n', os.linesep.decode('utf-8')]: + for eol in ['\r\n', '\r', '\n', os.linesep]: lines = [splitline for line in lines for splitline in line.split(eol)] vim.current.buffer[:] = lines