Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting completion params for hashlib.blake2b #1031

Closed
hansonw opened this issue Jan 23, 2018 · 2 comments
Closed

Error getting completion params for hashlib.blake2b #1031

hansonw opened this issue Jan 23, 2018 · 2 comments

Comments

@hansonw
Copy link

hansonw commented Jan 23, 2018

I'm able to consistently reproduce a RuntimeError running this code with Python 3.6.2 on MacOS:

>>> import jedi
>>> script = jedi.api.Script(source='from hashlib import ', line=1, column=20)
>>> c = script.completions()
>>> c[2]
<Completion: blake2b>
>>> c[2].params
Traceback (most recent call last):
  File "jedi/cache.py", line 116, in wrapper
    return dct[key]
KeyError: ((), frozenset())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 1978, in wrap_value
    value = eval(s, module_dict)
  File "<string>", line 1, in <module>
NameError: name '_blake2b' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 1981, in wrap_value
    value = eval(s, sys_module_dict)
  File "<string>", line 1, in <module>
NameError: name '_blake2b' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "jedi/cache.py", line 118, in wrapper
    result = method(self, *args, **kwargs)
  File "jedi/api/classes.py", line 350, in params
    return [Definition(self._evaluator, n) for n in get_param_names(context)]
  File "jedi/api/classes.py", line 342, in get_param_names
    return list(context.get_param_names())
  File "jedi/evaluate/compiled/__init__.py", line 139, in get_param_names
    signature = inspect.signature(obj)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 3033, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 2783, in from_callable
    follow_wrapper_chains=follow_wrapped)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 2324, in _signature_from_callable
    return _signature_fromstr(sigcls, obj, text_sig)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 2049, in _signature_fromstr
    p(name, default)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 2019, in p
    default_node = RewriteSymbolics().visit(default_node)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 253, in visit
    return visitor(node)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 2006, in visit_Attribute
    return wrap_value(value)
  File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 1983, in wrap_value
    raise RuntimeError()

There aren't any references to _blake2b in the actual hashlib.py library code, so the error seems pretty unusual. Is this a known issue? Thanks!

facebook-github-bot pushed a commit to facebookarchive/nuclide that referenced this issue Jan 25, 2018
Summary:
Just using the generic autocompletion cache seems fine.

I also noticed a `RuntimeError` being occasionally thrown on completion: I've added a `catch` for that and filed an issue at davidhalter/jedi#1031.

Reviewed By: pelmers

Differential Revision: D6781655

fbshipit-source-id: 38cf49422632757001f07855736f4582f45e1546
@davidhalter
Copy link
Owner

Thanks for the detailed report.

This is definitely not a known issue. It looks like inspect.signature(obj) raises a RuntimeError. This feels very unusual and as probably not happened before.

I can even reproduce this one on linux. Let me investigate a bit. My first impression is that inspect.signature raises all sorts of errors that we basically just want to ignore...

@davidhalter
Copy link
Owner

davidhalter commented Jan 26, 2018

Fixed in the virtualenv branch. Might take a month or even a bit more until that one is released.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants