mozilla/dxr

The python plugin is broken

kyakovenko opened this issue · 1 comments

Hello guys,

It seems the 348026a has broken the python plugin because it can no longer handle function calls, e.g. an indexing of the following example:

import collections
Person = collections.namedtuple('Person', 'name age gender')

produces next output:

Traceback (most recent call last):
  File "/home/vagrant/venv/bin/dxr", line 9, in <module>
    load_entry_point('dxr==2.0', 'console_scripts', 'dxr')()
  File "/home/vagrant/dxr/dxr/cli/__init__.py", line 29, in main
    return dxr.invoke(ctx)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/vagrant/dxr/dxr/cli/index.py", line 26, in index
    index_and_deploy_tree(tree, verbose=verbose)
  File "/home/vagrant/dxr/dxr/build.py", line 64, in index_and_deploy_tree
    index_name = index_tree(tree, es, verbose=verbose)
  File "/home/vagrant/dxr/dxr/build.py", line 275, in index_tree
    index_files(tree, tree_indexers, index, pool, es)
  File "/home/vagrant/dxr/dxr/build.py", line 628, in index_files
    swallow_exc=False)
  File "/home/vagrant/dxr/dxr/build.py", line 581, in index_chunk
    index_file(tree, tree_indexers, path, es, index)
  File "/home/vagrant/dxr/dxr/build.py", line 482, in index_file
    refses.append(file_to_index.refs())
  File "/home/vagrant/dxr/dxr/plugins/python/indexers.py", line 216, in refs
    return self.visitor.refs
  File "/home/vagrant/dxr/dxr/plugins/python/indexers.py", line 195, in visitor
    self._visitor.visit(syntax_tree)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/usr/lib/python2.7/ast.py", line 249, in generic_visit
    self.visit(item)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/usr/lib/python2.7/ast.py", line 251, in generic_visit
    self.visit(value)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/home/vagrant/dxr/dxr/plugins/python/indexers.py", line 100, in visit_Call
    start, end = self.file_to_index.get_node_start_end(node)
  File "/home/vagrant/dxr/dxr/plugins/python/indexers.py", line 295, in get_node_start_end
    start, end = self.call_start_table[loc]
KeyError: (10, 9)

Specifically, we now have problems with method calls. @jbradberry pointed this out Friday and is working on a fix. Thanks for the report!