<div dir="auto">Shouldn't this at least use >=? (But it feels like there is probably a way that doesn't have to do UA sniffing, so to speak)</div><div class="gmail_extra"><br><div class="gmail_quote">On Dec 9, 2016 8:04 PM, "Vedant Kumar via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vedantk<br>
Date: Fri Dec  9 18:54:13 2016<br>
New Revision: 289308<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=289308&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=289308&view=rev</a><br>
Log:<br>
[clang-format] Another attempt at python 3 compatibility<br>
<br>
The entries in vim.current.buffer appear to be decoded strings, which<br>
means that python3 won't allow invoking 'decode' on them. Keep the old<br>
behavior when running under python2, but skip the error-inducing decode<br>
step with python3..<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=289308&r1=289307&r2=289308&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>format/clang-format.py?rev=<wbr>289308&r1=289307&r2=289308&<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 Fri Dec  9 18:54:13 2016<br>
@@ -29,6 +29,7 @@ from __future__ import print_function<br>
<br>
 import difflib<br>
 import json<br>
+import platform<br>
 import subprocess<br>
 import sys<br>
 import vim<br>
@@ -48,10 +49,15 @@ fallback_style = None<br>
 if vim.eval('exists("g:clang_<wbr>format_fallback_style")') == "1":<br>
   fallback_style = vim.eval('g:clang_format_<wbr>fallback_style')<br>
<br>
+def get_buffer(encoding):<br>
+  if platform.python_version_tuple(<wbr>)[0] == '3':<br>
+    return vim.current.buffer<br>
+  return [ line.decode(encoding) for line in vim.current.buffer ]<br>
+<br>
 def main():<br>
   # Get the current text.<br>
   encoding = vim.eval("&encoding")<br>
-  buf = [ line.decode(encoding) for line in vim.current.buffer ]<br>
+  buf = get_buffer(encoding)<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>
</blockquote></div></div>