forked from VimPlug/jedi
Merge pull request #232 from tkf/unicode-has-no-generate_call_path
Fix: 'unicode' object has no attribute 'generate_call_path'
This commit is contained in:
@@ -391,7 +391,9 @@ class Script(object):
|
|||||||
defs, search_name = evaluate.goto(stmt)
|
defs, search_name = evaluate.goto(stmt)
|
||||||
definitions = follow_inexistent_imports(defs)
|
definitions = follow_inexistent_imports(defs)
|
||||||
if isinstance(user_stmt, pr.Statement):
|
if isinstance(user_stmt, pr.Statement):
|
||||||
if user_stmt.get_commands()[0].start_pos > self.pos:
|
call = user_stmt.get_commands()[0]
|
||||||
|
if not isinstance(call, (str, unicode)) and \
|
||||||
|
call.start_pos > self.pos:
|
||||||
# The cursor must be after the start, otherwise the
|
# The cursor must be after the start, otherwise the
|
||||||
# statement is just an assignee.
|
# statement is just an assignee.
|
||||||
definitions = [user_stmt]
|
definitions = [user_stmt]
|
||||||
|
|||||||
@@ -794,7 +794,10 @@ def goto(stmt, call_path=None):
|
|||||||
commands = stmt.get_commands()
|
commands = stmt.get_commands()
|
||||||
assert len(commands) == 1
|
assert len(commands) == 1
|
||||||
call = commands[0]
|
call = commands[0]
|
||||||
call_path = list(call.generate_call_path())
|
if isinstance(call, (str, unicode)):
|
||||||
|
call_path = [call]
|
||||||
|
else:
|
||||||
|
call_path = list(call.generate_call_path())
|
||||||
|
|
||||||
scope = stmt.get_parent_until(pr.IsScope)
|
scope = stmt.get_parent_until(pr.IsScope)
|
||||||
pos = stmt.start_pos
|
pos = stmt.start_pos
|
||||||
|
|||||||
@@ -329,6 +329,14 @@ class TestRegression(TestBase):
|
|||||||
defs = self.goto_definitions("assert")
|
defs = self.goto_definitions("assert")
|
||||||
assert len(defs) == 1
|
assert len(defs) == 1
|
||||||
|
|
||||||
|
def test_goto_assignments_keyword(self):
|
||||||
|
"""
|
||||||
|
Bug: goto assignments on ``in`` used to raise AttributeError::
|
||||||
|
|
||||||
|
'unicode' object has no attribute 'generate_call_path'
|
||||||
|
"""
|
||||||
|
self.goto_assignments('in')
|
||||||
|
|
||||||
def test_goto_following_on_imports(self):
|
def test_goto_following_on_imports(self):
|
||||||
s = "import multiprocessing.dummy; multiprocessing.dummy"
|
s = "import multiprocessing.dummy; multiprocessing.dummy"
|
||||||
g = self.goto_assignments(s)
|
g = self.goto_assignments(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user