Python 3.7: RuntimeError: generator raised StopIteration
Using cppclean with Python 3.7 results in a RuntimeError for most of our Projects. It's probably a result of PEP 479: https://www.python.org/dev/peps/pep-0479/
Traceback (most recent call last):
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 887, in _get_matching_char
token = get_next_token()
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 904, in _get_next_token
return next(self.tokens)
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\Python37\Scripts\cppclean", line 166, in <module>
sys.exit(main())
File "C:\Program Files\Python37\Scripts\cppclean", line 159, in main
quiet=args.quiet):
File "c:\program files\python37\lib\site-packages\cpp\find_warnings.py", line 633, in run
hunter.find_warnings()
File "c:\program files\python37\lib\site-packages\cpp\find_warnings.py", line 129, in find_warnings
self._find_source_warnings()
File "c:\program files\python37\lib\site-packages\cpp\find_warnings.py", line 575, in _find_source_warnings
included_files, forward_declarations = self._read_and_parse_includes()
File "c:\program files\python37\lib\site-packages\cpp\find_warnings.py", line 182, in _read_and_parse_includes
module = self._get_module(node)
File "c:\program files\python37\lib\site-packages\cpp\find_warnings.py", line 156, in _get_module
ast_list = [_f for _f in builder.generate() if _f]
File "c:\program files\python37\lib\site-packages\cpp\find_warnings.py", line 156, in <listcomp>
ast_list = [_f for _f in builder.generate() if _f]
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 675, in generate
result = self._generate_one(token)
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 702, in _generate_one
return method()
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 1441, in handle_template
templated_types)
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 1601, in _get_class
return self._get_method(name_tokens, 0, None, False)
File "c:\program files\python37\lib\site-packages\cpp\ast.py", line 1009, in _get_method
parameters = list(self._get_parameters())
RuntimeError: generator raised StopIteration
I had the same errors on classes that had some kind of export macro and are final at same time: class EXPORT_MACRO Foo final {}; I made a small PR (https://github.com/myint/cppclean/pull/152) to fix the issue. It works for me, maybe it also helps you.
It fixes some of the errors but not all
Sorry for the slow reply. Yes, I also have still some issues. I might look into them at some point. Meanwhile for me I just changed the code a bit to ignore the thrown RuntimeError, such that at least the remaining files are processed