r196484 - clang-format-diff.py: pass through errors to stderr, not stdout

Alp Toker alp at nuanti.com
Thu Dec 5 00:14:54 PST 2013


Author: alp
Date: Thu Dec  5 02:14:54 2013
New Revision: 196484

URL: http://llvm.org/viewvc/llvm-project?rev=196484&view=rev
Log:
clang-format-diff.py: pass through errors to stderr, not stdout

Also use write() for unified diff output to avoid further processing by the
print function (e.g. trailing newline).

Modified:
    cfe/trunk/tools/clang-format/clang-format-diff.py

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=196484&r1=196483&r2=196484&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Thu Dec  5 02:14:54 2013
@@ -85,11 +85,8 @@ def main():
     if args.style:
       command.extend(['-style', args.style])
     p = subprocess.Popen(command, stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE,
-                         stdin=subprocess.PIPE)
+                         stderr=None, stdin=subprocess.PIPE)
     stdout, stderr = p.communicate()
-    if stderr:
-      print stderr
     if p.returncode != 0:
       sys.exit(p.returncode);
 
@@ -102,7 +99,7 @@ def main():
                                   '(before formatting)', '(after formatting)')
       diff_string = string.join(diff, '')
       if len(diff_string) > 0:
-        print diff_string
+        sys.stdout.write(diff_string)
 
 if __name__ == '__main__':
   main()





More information about the cfe-commits mailing list