X Tutup
Skip to content

Guard against jedi completion errors better #483

@thomasballinger

Description

@thomasballinger
bpython version 0.15.dev4 on top of Python 2.7.9 /Users/tomb/.virtualenvs/bpython/bin/python2.7
>>>
>>>
>>>
>>>
>>> class Foo():
...     return x + 1
Traceback (most recent call last):
  File "/Users/tomb/.virtualenvs/bpython/bin/bpython", line 9, in <module>
    load_entry_point('bpython==0.15.dev4', 'console_scripts', 'bpython')()
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsies.py", line 79, in main
    interactive=(not exec_args))
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsies.py", line 177, in mainloop
    process_event(e)
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsies.py", line 135, in process_event
    repl.process_event(e)
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsiesfrontend/repl.py", line 487, in process_event
    return self.process_key_event(e)
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsiesfrontend/repl.py", line 563, in process_key_event
    self.cursor_offset = len(self.current_line)
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsiesfrontend/repl.py", line 1344, in _set_cursor_offset
    self.update_completion()
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsiesfrontend/repl.py", line 877, in update_completion
    self.list_win_visible = BpythonRepl.complete(self, tab)
  File "/Users/tomb/Dropbox/code/bpython/bpython/repl.py", line 606, in complete
    history=self.history)
  File "/Users/tomb/Dropbox/code/bpython/bpython/autocomplete.py", line 455, in get_completer_bpython
    return get_completer(BPYTHON_COMPLETER, cursor_offset, line, **kwargs)
  File "/Users/tomb/Dropbox/code/bpython/bpython/autocomplete.py", line 434, in get_completer
    cursor_offset, line, **kwargs)
  File "/Users/tomb/Dropbox/code/bpython/bpython/autocomplete.py", line 409, in matches
    history=history)
  File "/Users/tomb/Dropbox/code/bpython/bpython/autocomplete.py", line 369, in matches
    completions = script.completions()
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/api/__init__.py", line 155, in completions
    user_stmt = self._parser.user_stmt_with_whitespace()
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/cache.py", line 139, in wrapper
    result = func(self)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/user_context.py", line 226, in user_stmt_with_whitespace
    user_stmt = self.user_stmt()
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/cache.py", line 139, in wrapper
    result = func(self)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/user_context.py", line 216, in user_stmt
    module = self.module()
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/user_context.py", line 255, in module
    return self._parser().module
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/cache.py", line 139, in wrapper
    result = func(self)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/user_context.py", line 209, in _parser
    parser = FastParser(self._source, self._path)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/fast.py", line 65, in __call__
    p = super(CachedFastParser, self).__call__(source, module_path)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/fast.py", line 199, in __init__
    self._parse(code)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/fast.py", line 302, in _parse
    line_offset, nodes, not is_first)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/fast.py", line 367, in _get_parser
    top_module=self.module, no_docstr=no_docstr)
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/__init__.py", line 59, in __init__
    self._parse()
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/__init__.py", line 567, in _parse
    func.statements.append(pr.KeywordStatement(tok_str, s,
  File "/Users/tomb/.virtualenvs/bpython/lib/python2.7/site-packages/jedi/parser/fast.py", line 38, in __getattr__
    return getattr(self.parsers[0].module, name)
IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup