[PATCH] D76381: Fix AttributeError in add_new_check.py

Jens Carl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 18 13:02:08 PDT 2020


j-carl created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
j-carl added a reviewer: alexfh.
j-carl edited the summary of this revision.
j-carl added a project: clang-tools-extra.

Using add_new_check.py with Python 3.8.2 to create a new check results
in a AttributeError and an empty file <module>/<Module>TidyModule.cpp.

Python 3.x doesn't support `next()` anymore and should be replace with
`__next__()`.

$ ./add_new_check.py readability test-flag
Updating ./readability/CMakeLists.txt...
Creating ./readability/TestFlagCheck.h...
Creating ./readability/TestFlagCheck.cpp...
Updating ./readability/ReadabilityTidyModule.cpp...
Traceback (most recent call last):

  File "./add_new_check.py", line 471, in <module>
    main()
  File "./add_new_check.py", line 461, in main
    adapt_module(module_path, module, check_name, check_name_camel)
  File "./add_new_check.py", line 175, in adapt_module
    line = lines.next()

AttributeError: 'list_iterator' object has no attribute 'next'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76381

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


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
@@ -172,7 +172,7 @@
     lines = iter(lines)
     try:
       while True:
-        line = lines.next()
+        line = lines.__next__()
         if not header_added:
           match = re.search('#include "(.*)"', line)
           if match:
@@ -197,7 +197,7 @@
                 # If we didn't find the check name on this line, look on the
                 # next one.
                 prev_line = line
-                line = lines.next()
+                line = lines.__next__()
                 match = re.search(' *"([^"]*)"', line)
                 if match:
                   current_check_name = match.group(1)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76381.251151.patch
Type: text/x-patch
Size: 839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200318/02800b0f/attachment-0001.bin>


More information about the cfe-commits mailing list