r285301 - Attempt to make clang-format.py python 3 - compatible.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 8 06:51:50 PST 2016


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?

On Wed, Dec 7, 2016 at 6:59 AM, Vedant Kumar <vsk at apple.com> wrote:

> Hi Alexander,
>
> I think this will cause an error if used with python3 (at least, it fails
> on my
> system). Here's the problem:
>
>   line.decode(encoding)
>
> When vim is compiled against python3, the type of 'line' remains 'str' --
> not
> 'bytes'. There isn't a 'decode' method on strings: it only exists for
> bytes. I
> take this to mean that vim has done the decoding already. If not, there's
> a bug
> in vim.
>
> I've attached a small patch that addresses this issue. Wdyt?
>
>
>
>
> thanks,
> vedant
>
>
> > On Oct 27, 2016, at 8:15 AM, Alexander Kornienko via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> >
> > Author: alexfh
> > Date: Thu Oct 27 10:15:23 2016
> > New Revision: 285301
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=285301&view=rev
> > Log:
> > Attempt to make clang-format.py python 3 - compatible.
> >
> > Modified:
> >    cfe/trunk/tools/clang-format/clang-format.py
> >
> > Modified: cfe/trunk/tools/clang-format/clang-format.py
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-
> format/clang-format.py?rev=285301&r1=285300&r2=285301&view=diff
> > ============================================================
> ==================
> > --- cfe/trunk/tools/clang-format/clang-format.py (original)
> > +++ cfe/trunk/tools/clang-format/clang-format.py Thu Oct 27 10:15:23
> 2016
> > @@ -51,7 +51,7 @@ if vim.eval('exists("g:clang_format_fall
> > def main():
> >   # Get the current text.
> >   encoding = vim.eval("&encoding")
> > -  buf = [ unicode(line, encoding) for line in vim.current.buffer ]
> > +  buf = [ line.decode(encoding) for line in vim.current.buffer ]
> >   text = '\n'.join(buf)
> >
> >   # Determine range to format.
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161208/565c3e83/attachment.html>


More information about the cfe-commits mailing list