git-afsantos / haros

H(igh) A(ssurance) ROS - Static analysis of ROS application code.
MIT License
190 stars 37 forks source link

AttributeError: 'Call' object has no attribute 'starargs' when parsing Python code #115

Closed git-afsantos closed 2 years ago

git-afsantos commented 2 years ago

This error shows up when parsing basic Python nodes.

The issue seems to be in the bonsai.py parser, though.

Traceback (most recent call last):
  File "/usr/local/bin/haros", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/haros/haros.py", line 1055, in main
    if launcher.launch(argv=argv):
  File "/usr/local/lib/python3.8/dist-packages/haros/haros.py", line 194, in launch
    return command(args)
  File "/usr/local/lib/python3.8/dist-packages/haros/haros.py", line 217, in command_full
    return self.command_analyse(args) and self.command_viz(args)
  File "/usr/local/lib/python3.8/dist-packages/haros/haros.py", line 238, in command_analyse
    return analyse.run()
  File "/usr/local/lib/python3.8/dist-packages/haros/haros.py", line 668, in run
    configs, nodes, env = self._extract_metamodel(node_cache, rules)
  File "/usr/local/lib/python3.8/dist-packages/haros/haros.py", line 694, in _extract_metamodel
    extractor.index_source(settings = self.settings)
  File "/usr/local/lib/python3.8/dist-packages/haros/extractor.py", line 182, in index_source
    self._find_nodes(settings)
  File "/usr/local/lib/python3.8/dist-packages/haros/extractor.py", line 352, in _find_nodes
    extractor.find_nodes(pkg)
  File "/usr/local/lib/python3.8/dist-packages/haros/extractor.py", line 1091, in find_nodes
    self._extract_primitives()
  File "/usr/local/lib/python3.8/dist-packages/haros/extractor.py", line 1153, in _extract_primitives
    self.rospy_extractor = RospyExtractor(self.package, self.workspace)
  File "/usr/local/lib/python3.8/dist-packages/haros/extractor.py", line 1949, in __init__
    self.pythonpath = self._setup_path()
  File "/usr/local/lib/python3.8/dist-packages/haros/extractor.py", line 1923, in _setup_path
    setup = parser.parse(setup_file)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/py_parser.py", line 221, in parse
    node, imported_names = self._parse_file(file_path)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/py_parser.py", line 197, in _parse_file
    node, imported_names = BuilderVisitor().build(py_tree, file_path)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/visitor.py", line 186, in build
    self.visit(node)
  File "/usr/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/visitor.py", line 115, in builder_visit
    children_visitor.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 379, in generic_visit
    self.visit(item)
  File "/usr/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/visitor.py", line 115, in builder_visit
    children_visitor.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 381, in generic_visit
    self.visit(value)
  File "/usr/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/visitor.py", line 106, in builder_visit
    bonsai_node, children_scope, props = visitor_method(node)
  File "/usr/local/lib/python3.8/dist-packages/bonsai/py/visitor.py", line 240, in visit_Call
    'has_starargs': py_node.starargs is not None,
AttributeError: 'Call' object has no attribute 'starargs'
git-afsantos commented 2 years ago

Fixed as of https://github.com/git-afsantos/bonsai/commit/c9f25c6e25eabe3367bba679564e6b9272148690