<div dir="ltr">If this fixes the problem on python 3 (and it leaves the current behavior on python 2), then it looks good. Can you submit it?</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 7, 2016 at 6:59 AM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alexander,<br>
<br>
I think this will cause an error if used with python3 (at least, it fails on my<br>
system). Here's the problem:<br>
<br>
line.decode(encoding)<br>
<br>
When vim is compiled against python3, the type of 'line' remains 'str' -- not<br>
'bytes'. There isn't a 'decode' method on strings: it only exists for bytes. I<br>
take this to mean that vim has done the decoding already. If not, there's a bug<br>
in vim.<br>
<br>
I've attached a small patch that addresses this issue. Wdyt?<br>
<br>
<br><br>
<br>
thanks,<br>
vedant<br>
<br>
<br>
> On Oct 27, 2016, at 8:15 AM, Alexander Kornienko via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: alexfh<br>
> Date: Thu Oct 27 10:15:23 2016<br>
> New Revision: 285301<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=285301&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=285301&view=rev</a><br>
> Log:<br>
> Attempt to make clang-format.py python 3 - compatible.<br>
><br>
> Modified:<br>
> cfe/trunk/tools/clang-format/<wbr>clang-format.py<br>
><br>
> Modified: cfe/trunk/tools/clang-format/<wbr>clang-format.py<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=285301&r1=285300&r2=285301&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>format/clang-format.py?rev=<wbr>285301&r1=285300&r2=285301&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/tools/clang-format/<wbr>clang-format.py (original)<br>
> +++ cfe/trunk/tools/clang-format/<wbr>clang-format.py Thu Oct 27 10:15:23 2016<br>
> @@ -51,7 +51,7 @@ if vim.eval('exists("g:clang_<wbr>format_fall<br>
> def main():<br>
> # Get the current text.<br>
> encoding = vim.eval("&encoding")<br>
> - buf = [ unicode(line, encoding) for line in vim.current.buffer ]<br>
> + buf = [ line.decode(encoding) for line in vim.current.buffer ]<br>
> text = '\n'.join(buf)<br>
><br>
> # Determine range to format.<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br>
<br></blockquote></div><br></div>