mattbeardsley created this revision.
mattbeardsley added a reviewer: kbobyrev.
mattbeardsley requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

As of this commit:

  https://github.com/llvm/llvm-project/commit/307b1fdd

If either of those scripts are invoked with python 2, neither works due to:

  "TypeError: write() argument 1 must be unicode, not str"

Figured I'd send a quick review for the easier fix of "just use python 3", given
that these scripts already don't work with python 2.

Let me know if these are indeed expected/required to continue working with
python 2 though, and I'll look into fixing the "f.write" calls instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109127

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py


Index: clang-tools-extra/clang-tidy/rename_check.py
===================================================================
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- rename_check.py - clang-tidy check renamer ------------*- python -*--===#
 #
@@ -13,6 +13,9 @@
 import io
 import os
 import re
+import sys
+
+assert sys.version_info >= (3,), "Requires python 3"
 
 def replaceInFileRegex(fileName, sFrom, sTo):
   if sFrom == sTo:
Index: clang-tools-extra/clang-tidy/add_new_check.py
===================================================================
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- add_new_check.py - clang-tidy check generator ---------*- python -*--===#
 #
@@ -16,6 +16,8 @@
 import re
 import sys
 
+assert sys.version_info >= (3,), "Requires python 3"
+
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):


Index: clang-tools-extra/clang-tidy/rename_check.py
===================================================================
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- rename_check.py - clang-tidy check renamer ------------*- python -*--===#
 #
@@ -13,6 +13,9 @@
 import io
 import os
 import re
+import sys
+
+assert sys.version_info >= (3,), "Requires python 3"
 
 def replaceInFileRegex(fileName, sFrom, sTo):
   if sFrom == sTo:
Index: clang-tools-extra/clang-tidy/add_new_check.py
===================================================================
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- add_new_check.py - clang-tidy check generator ---------*- python -*--===#
 #
@@ -16,6 +16,8 @@
 import re
 import sys
 
+assert sys.version_info >= (3,), "Requires python 3"
+
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D109127: Use python... Matt Beardsley via Phabricator via cfe-commits

Reply via email to