forked from VimPlug/jedi
In some very rare cases it was possible to get an interpreter crash because of this bug. Fixes #1087
This commit is contained in:
@@ -166,11 +166,10 @@ def _find_syntax_node_name(evaluator, access_handle):
|
|||||||
return None # It's too hard to find lambdas.
|
return None # It's too hard to find lambdas.
|
||||||
|
|
||||||
# Doesn't always work (e.g. os.stat_result)
|
# Doesn't always work (e.g. os.stat_result)
|
||||||
try:
|
names = module_node.get_used_names().get(name_str, [])
|
||||||
names = module_node.get_used_names()[name_str]
|
|
||||||
except KeyError:
|
|
||||||
return None
|
|
||||||
names = [n for n in names if n.is_definition()]
|
names = [n for n in names if n.is_definition()]
|
||||||
|
if not names:
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
code = python_object.__code__
|
code = python_object.__code__
|
||||||
|
|||||||
@@ -341,3 +341,18 @@ def test_dir_magic_method():
|
|||||||
|
|
||||||
foo = [c for c in completions if c.name == 'foo'][0]
|
foo = [c for c in completions if c.name == 'foo'][0]
|
||||||
assert foo._goto_definitions() == []
|
assert foo._goto_definitions() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_name_not_findable():
|
||||||
|
class X():
|
||||||
|
if 0:
|
||||||
|
NOT_FINDABLE
|
||||||
|
|
||||||
|
def hidden(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
hidden.__name__ = 'NOT_FINDABLE'
|
||||||
|
|
||||||
|
setattr(X, 'NOT_FINDABLE', X.hidden)
|
||||||
|
|
||||||
|
assert jedi.Interpreter("X.NOT_FINDA", [locals()]).completions()
|
||||||
|
|||||||
Reference in New Issue
Block a user