IndexError: pop from empty list
Ran this on my code base. I handle dependencies as git submodules, so they're all in my working tree and cppclean ran on all of them. It spit out a bunch of warnings, then a stack trace:
Traceback (most recent call last):
File "/usr/local/bin/cppclean", line 145, in <module>
sys.exit(main())
File "/usr/local/bin/cppclean", line 120, in main
entire_ast = list([_f for _f in builder.generate() if _f])
File "/usr/local/bin/cppclean", line 120, in <listcomp>
entire_ast = list([_f for _f in builder.generate() if _f])
File "/usr/local/lib/python3.5/dist-packages/cpp/ast.py", line 647, in generate
if self.namespaces.pop():
IndexError: pop from empty list
I'm seeing the same issue, with the same stack trace (although I'm on Python 3.6).
I'm getting this issue as well, using Python 2.7, with a similar but longer stacktrace:
File "c:\Python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\cppclean.py", line 145, in <module>
sys.exit(main())
File "C:\Python27\Scripts\cppclean.py", line 138, in main
quiet=args.quiet):
File "c:\Python27\lib\site-packages\cpp\find_warnings.py", line 597, in run
hunter.find_warnings()
File "c:\Python27\lib\site-packages\cpp\find_warnings.py", line 126, in find_warnings
self._find_source_warnings()
File "c:\Python27\lib\site-packages\cpp\find_warnings.py", line 542, in _find_source_warnings
included_files, forward_declarations = self._read_and_parse_includes()
File "c:\Python27\lib\site-packages\cpp\find_warnings.py", line 177, in _read_and_parse_includes
module = self._get_module(node)
File "c:\Python27\lib\site-packages\cpp\find_warnings.py", line 151, in _get_module
ast_list = [_f for _f in builder.generate() if _f]
File "c:\Python27\lib\site-packages\cpp\ast.py", line 651, in generate
result = self._generate_one(token)
File "c:\Python27\lib\site-packages\cpp\ast.py", line 675, in _generate_one
return method()
File "c:\Python27\lib\site-packages\cpp\ast.py", line 1177, in handle_class
return self._handle_class_and_struct(Class)
File "c:\Python27\lib\site-packages\cpp\ast.py", line 1174, in _handle_class_and_struct
return self._get_class(class_type, None)
File "c:\Python27\lib\site-packages\cpp\ast.py", line 1486, in _get_class
body = list(ast.generate())
File "c:\Python27\lib\site-packages\cpp\ast.py", line 651, in generate
result = self._generate_one(token)
File "c:\Python27\lib\site-packages\cpp\ast.py", line 675, in _generate_one
return method()
File "c:\Python27\lib\site-packages\cpp\ast.py", line 1180, in handle_struct
return self._handle_class_and_struct(Struct)
File "c:\Python27\lib\site-packages\cpp\ast.py", line 1174, in _handle_class_and_struct
return self._get_class(class_type, None)
File "c:\Python27\lib\site-packages\cpp\ast.py", line 1486, in _get_class
body = list(ast.generate())
File "c:\Python27\lib\site-packages\cpp\ast.py", line 647, in generate
if self.namespaces.pop():
IndexError: pop from empty list
Already fixed, likely by https://github.com/myint/cppclean/commit/4d695a63cd74f9fc434a4626430d6a353e6f7eba
Hi,
I installed using 'pip install --upgrade cppclean' with python 2.7.6 and I still got this error.
I saw that it was fixed on Github, but it installed an older version of 'ast.py' which doesn't contain the fix.
I am now receiving this error.
Traceback (most recent call last):
File "/home/stack/.local/bin/cppclean", line 166, in <module>
sys.exit(main())
File "/home/stack/.local/bin/cppclean", line 155, in main
if module.run(filename, source, entire_ast,
File "/home/stack/.local/lib/python3.9/site-packages/cpp/find_warnings.py", line 633, in run
hunter.find_warnings()
File "/home/stack/.local/lib/python3.9/site-packages/cpp/find_warnings.py", line 129, in find_warnings
self._find_source_warnings()
File "/home/stack/.local/lib/python3.9/site-packages/cpp/find_warnings.py", line 575, in _find_source_warnings
included_files, forward_declarations = self._read_and_parse_includes()
File "/home/stack/.local/lib/python3.9/site-packages/cpp/find_warnings.py", line 182, in _read_and_parse_includes
module = self._get_module(node)
File "/home/stack/.local/lib/python3.9/site-packages/cpp/find_warnings.py", line 156, in _get_module
ast_list = [_f for _f in builder.generate() if _f]
File "/home/stack/.local/lib/python3.9/site-packages/cpp/find_warnings.py", line 156, in <listcomp>
ast_list = [_f for _f in builder.generate() if _f]
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 675, in generate
result = self._generate_one(token)
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 702, in _generate_one
return method()
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 1440, in handle_template
return self._get_class(Class,
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 1558, in _get_class
body = list(ast.generate())
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 675, in generate
result = self._generate_one(token)
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 702, in _generate_one
return method()
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 1457, in handle_template
return self.get_method(FUNCTION_NONE, templated_types)
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 947, in get_method
return self._get_method(
File "/home/stack/.local/lib/python3.9/site-packages/cpp/ast.py", line 994, in _get_method
name = return_type_and_name.pop()
IndexError: pop from empty list
Installed today with pip install --upgrade cppclean
I am getting the same error as StackDoubleFlow.
OK, after some further investigation, it appears that this happens because of the spaceship operator. This is the line of code that causes cppclean to get tripped up for me:
friend int operator<=>(const VersionNumber &a, const VersionNumber &b);