jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.89k stars 260 forks source link

Backend Encountered An Unexpected Bug #926

Open hnisonoff opened 8 years ago

hnisonoff commented 8 years ago

Elpy Error

The backend encountered an unexpected error. This indicates a bug in Elpy. Please open a bug report with the data below in the Elpy bug tracker:

https://github.com/jorgenschaefer/elpy/issues/new

Error Message

__init__() got an unexpected keyword argument 'encoding'

Configuration

Virtualenv........: None
RPC Python........: 2.7.6 (/usr/bin/python)
Interactive Python: ipython (/usr/bin/ipython)
Emacs.............: 24.5.1
Elpy..............: 1.8.0
Jedi..............: 0.7.0 (0.9.0 available)
Rope..............: Not found (0.10.3 available)
Importmagic.......: Not found (0.1.7 available)
Syntax checker....: flake8 (/home/home3/hmn5/.local/bin/flake8)

Traceback

Traceback (most recent call last):
  File "/home/home3/hmn5/.emacs.d/elpa/elpy-1.8.0/elpy/jedibackend.py", line 302, in run_with_debug
    script = jedi.Script(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'encoding'

Jedi Debug Information

Jedi did not emit any debug info.

Reproduction:

import jedi

source = '''\
#!/usr/bin/python

"""This script analyzes a structure and finds residues that clash with
the portion of the protein specified by staring and ending res
numbers"""

import sys
from Bio.PDB.PDBParser import PDBParser

if len(sys.argv) < 3:
    print("Usage ./findClashes.py yourPDBFile startResNum endResNum")
    sys.exit()

p = PDBParser(PERMISSIVE=1)
struct = p.get_structure(sys.argv[1][:-4], sys.argv[1])
resToCheck = [res for res in struct.g'''

script = jedi.Script(column=37, source=source, line=17, encoding='utf-8', path=u'/usr/project/dlab/Users/hunter/KaDEE/DataAnalysis/AntibodyLoops/vrc07/master/H3/OSPREY/Top10/findClashes.py')
script.completions()
jorgenschaefer commented 8 years ago

Hello, and thanks for the report!

Jedi..............: 0.7.0 (0.9.0 available)

Could you upgrade Jedi and see if that solves the problem?

hnisonoff commented 8 years ago

Thanks for the reply!

I still received this error.

Elpy Error

The backend encountered an unexpected error. This indicates a bug in Elpy. Please open a bug report with the data below in the Elpy bug tracker:

https://github.com/jorgenschaefer/elpy/issues/new

Error Message

u'struct'

Configuration

Virtualenv........: hunternisonoff (/Users/hunternisonoff)
RPC Python........: 2.7.11 (/usr/local/bin/python)
Interactive Python: python (/usr/local/bin/python)
Emacs.............: 24.5.1
Elpy..............: 1.8.0
Jedi..............: 0.9.0
Rope..............: 0.10.3
Importmagic.......: 0.1.7
Syntax checker....: flake8 (/Library/Frameworks/Python.framework/Versions/3.5/bin/flake8)

Traceback

Traceback (most recent call last):
  File "/Users/hunternisonoff/.emacs.d/elpa/elpy-1.8.0/elpy/jedibackend.py", line 303, in run_with_debug
    return getattr(script, name)()
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 185, in completions
    user_stmt = self._parser.user_stmt_with_whitespace()
  File "/usr/local/lib/python2.7/site-packages/jedi/cache.py", line 143, in wrapper
    result = func(self)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/user_context.py", line 303, in user_stmt_with_whitespace
    user_stmt = self.user_stmt()
  File "/usr/local/lib/python2.7/site-packages/jedi/cache.py", line 143, in wrapper
    result = func(self)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/user_context.py", line 293, in user_stmt
    module = self.module()
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/user_context.py", line 339, in module
    return self._parser().module
  File "/usr/local/lib/python2.7/site-packages/jedi/cache.py", line 143, in wrapper
    result = func(self)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/user_context.py", line 283, in _parser
    parser = FastParser(self._grammar, self._source, self._path)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/fast.py", line 109, in __call__
    p.update(source)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/fast.py", line 257, in update
    self._parse(source)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/fast.py", line 383, in _parse
    line_offset, nodes)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/fast.py", line 435, in _get_node
    p = Parser(self._grammar, parser_code, self.module_path, tokenizer=tokenizer)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/__init__.py", line 155, in __init__
    self.module = p.parse(self._tokenize(tokenizer))
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/pgen2/parse.py", line 106, in parse
    if self.addtoken(type, value, prefix, start_pos):
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/pgen2/parse.py", line 170, in addtoken
    value, start_pos, prefix, self.addtoken)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/__init__.py", line 269, in error_recovery
    self._stack_removal(grammar, stack, index + 1, value, start_pos)
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/__init__.py", line 304, in _stack_removal
    clear_names(children=node[1])
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/__init__.py", line 298, in clear_names
    self._scope_names_stack[-1][c.value].remove(c)
KeyError: u'struct'

Jedi Debug Information

Jedi did not emit any debug info.

Reproduction:

import jedi

source = '''\
#!/usr/bin/python
from Bio.PDB import PDBParser

print(3+3)
p = PDBParser()
struct = p.get_structure('1get', '1get.pdb')
resList = struct.get_residues()
struct.get_atoms.map(lambda'''

script = jedi.Script(column=27, source=source, line=8, encoding='utf-8', path=u'/Users/hunternisonoff/test.py')
script.completions()
jorgenschaefer commented 8 years ago

Thank you! This looks like a new error, and seems to be a bug in Jedi. I'll report it upstream.