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

2016-12-09 Thread Vedant Kumar via cfe-commits
I confirmed that this works with :pyf and :py3f.

Committed in r289308.

thanks,
vedant

> On Dec 8, 2016, at 6:51 AM, Alexander Kornienko  wrote:
> 
> 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  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 
> >  wrote:
> >
> > Author: alexfh
> > Date: Thu Oct 27 10:15:23 2016
> > New Revision: 285301
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=285301=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=285300=285301=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("")
> > -  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@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
> 
> 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-12-08 Thread Alexander Kornienko via cfe-commits
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  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@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=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=285300=285301=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("")
> > -  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@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-12-06 Thread Vedant Kumar via cfe-commits
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?



cf.patch
Description: Binary data


thanks,
vedant


> On Oct 27, 2016, at 8:15 AM, Alexander Kornienko via cfe-commits 
>  wrote:
> 
> Author: alexfh
> Date: Thu Oct 27 10:15:23 2016
> New Revision: 285301
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285301=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=285300=285301=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("")
> -  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@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-10-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Oct 27 10:15:23 2016
New Revision: 285301

URL: http://llvm.org/viewvc/llvm-project?rev=285301=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=285300=285301=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("")
-  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@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits