davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.81k stars 508 forks source link

on youcompleteme, jedi (v0.9.0) crashes with `TypeError` #710

Closed timfeirg closed 8 years ago

timfeirg commented 8 years ago

I'm using youcomplete with vim, and jedi crashes whenever I triggered a autocomplete query against jediHTTP, here's the jedi error log:

Traceback (most recent call last):
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/bottle/bottle.py", line 862, in _handle
    return route.call(**args)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/bottle/bottle.py", line 1732, in wrapper
    rv = callback(*a, **ka)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/jedihttp/hmac_plugin.py", line 58, in wrapper
    body = callback( *args, **kwargs )
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/jedihttp/handlers.py", line 63, in completions
    } for completion in script.completions() ]
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/api/__init__.py", line 188, in completions
    completion_names = get_completions(user_stmt, b)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/api/__init__.py", line 174, in get_completions
    completion_names += self._simple_complete(path, dot, like)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/api/__init__.py", line 250, in _simple_complete
    scopes = list(self._prepare_goto(path, True))
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/api/__init__.py", line 294, in _prepare_goto
    scopes = self._evaluator.eval_element(eval_stmt)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/cache.py", line 41, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/__init__.py", line 169, in eval_element
    return self._eval_atom(element)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/__init__.py", line 230, in _eval_atom
    return self.find_types(scope, atom, stmt.start_pos, search_global=True)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/__init__.py", line 120, in find_types
    return f.find(scopes, search_global)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/debug.py", line 52, in wrapper
    result = func(*args, **kwargs)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/finder.py", line 87, in find
    types = self._names_to_types(names, search_global)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/finder.py", line 233, in _names_to_types
    new_types = _name_to_types(self._evaluator, name, self.scope)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/cache.py", line 41, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/finder.py", line 282, in _name_to_types
    types += imports.ImportWrapper(evaluator, name).follow()
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/cache.py", line 41, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/imports.py", line 94, in follow
    types = importer.follow()
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/cache.py", line 41, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/imports.py", line 252, in follow
    return self._do_import(self.import_path, self.sys_path_with_modifications())
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/imports.py", line 347, in _do_import
    module = _load_module(self._evaluator, module_path, source, sys_path)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/evaluate/imports.py", line 449, in _load_module
    cached = cache.load_parser(path)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/cache.py", line 210, in load_parser
    return ParserPickling.load_parser(path, p_time)
  File "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/cache.py", line 256, in load_parser
    pickle_changed_time = self._index[path]
TypeError: 'NoneType' object has no attribute '__getitem__'

I'm still having trouble deciding which vim plugin causes this exact problem, I'm not sure where to post this issue, I'm creating a issue here because the traceback points to jedi v0.9.0 which is the current release that jediHTTP uses.

reproduce

create a random python file with vim or neovim, and type in the following content:

import os
os.path

jedi will crash on the second line, after I type period and trigger a http query from youcompleteme, against jediHTTP, which eventually causes the crash in "/Users/timfeirg/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/vendor/jedi/jedi/cache.py", line 256, in load_parser

environment

NVIM v0.1.3-363-g2e2b575 youcompleteme 21a0019 which is the latest master, I also tried rollback a couple of commits, the problem still exists JediHTTP @ a645beb from latest ycmd

and like I said, I'm not very sure this is the place for this issue, it takes understanding of the three code bases (youcompleteme, jedi, jediHTTP) to determine which plugin causes the problem, appreciate it if anybody can take a look.

davidhalter commented 8 years ago

You might need to clean up Jedi's cache. Something might be corrupted. But I have no idea where the cache resides on Mac.

timfeirg commented 8 years ago

oh my god! rm -rf /Users/timfeirg/Library/Caches/Jedi totally fixes, thanks @davidhalter !!