1
0
forked from VimPlug/jedi

fixed dict problems

This commit is contained in:
David Halter
2013-02-20 22:37:32 +04:30
parent 06a54f30a8
commit f2cdf03e6e
2 changed files with 12 additions and 11 deletions

View File

@@ -838,16 +838,17 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)):
for i, key_statement in enumerate(self._array.keys):
# Because we only want the key to be a string.
key_commands = key_statement.get_commands()
if len(key_commands) == 1:
key = key_commands[0]
key.get_code()
try:
str_key = key.get_code()
except AttributeError:
str_key = None
if mixed_index == str_key:
index = i
break
if len(key_commands) != 1: # cannot deal with complex strings
continue
key = key_commands[0]
if isinstance(key, pr.Call) and key.type == pr.Call.STRING:
str_key = key.name
elif isinstance(key, pr.Name):
str_key = str(key)
if mixed_index == str_key:
index = i
break
if index is None:
raise KeyError('No key found in dictionary')