[PATCH] D109127: Use python 3 in add_new_check.py and rename_check.py
Matt Beardsley via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 1 20:36:14 PDT 2021
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):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109127.370151.patch
Type: text/x-patch
Size: 1202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210902/ac525226/attachment.bin>
More information about the cfe-commits
mailing list