mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-17 19:15:55 +08:00
fix problems with literals, finally
This commit is contained in:
@@ -529,8 +529,7 @@ class Script(object):
|
|||||||
if call is None:
|
if call is None:
|
||||||
user_stmt = self._user_stmt()
|
user_stmt = self._user_stmt()
|
||||||
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
|
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
|
||||||
call, index, _ = helpers.search_call_signatures(
|
call, index, _ = helpers.search_call_signatures(user_stmt, self._pos)
|
||||||
user_stmt, self._pos)
|
|
||||||
debug.speed('func_call parsed')
|
debug.speed('func_call parsed')
|
||||||
return call, index
|
return call, index
|
||||||
|
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ def check_getattr(inst, name_str):
|
|||||||
result = []
|
result = []
|
||||||
# str is important to lose the NamePart!
|
# str is important to lose the NamePart!
|
||||||
module = builtin.Builtin.scope
|
module = builtin.Builtin.scope
|
||||||
name = pr.String(module, str(name_str), (0, 0), (0, 0), inst)
|
name = pr.String(module, "'%s'" % name_str, (0, 0), (0, 0), inst)
|
||||||
with common.ignored(KeyError):
|
with common.ignored(KeyError):
|
||||||
result = inst.execute_subscope_by_name('__getattr__', [name])
|
result = inst.execute_subscope_by_name('__getattr__', [name])
|
||||||
if not result:
|
if not result:
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)):
|
|||||||
continue
|
continue
|
||||||
key = key_commands[0]
|
key = key_commands[0]
|
||||||
if isinstance(key, pr.String):
|
if isinstance(key, pr.String):
|
||||||
str_key = key.name
|
str_key = key.value
|
||||||
elif isinstance(key, pr.Name):
|
elif isinstance(key, pr.Name):
|
||||||
str_key = str(key)
|
str_key = str(key)
|
||||||
|
|
||||||
|
|||||||
@@ -123,12 +123,12 @@ def search_call_signatures(stmt, pos):
|
|||||||
# some parts will of the statement will be removed
|
# some parts will of the statement will be removed
|
||||||
stmt = fast_parent_copy(stmt)
|
stmt = fast_parent_copy(stmt)
|
||||||
arr, index = array_for_pos(stmt, pos, [pr.Array.TUPLE, pr.Array.NOARRAY])
|
arr, index = array_for_pos(stmt, pos, [pr.Array.TUPLE, pr.Array.NOARRAY])
|
||||||
if arr is not None and isinstance(arr.parent, pr.Call):
|
if arr is not None and isinstance(arr.parent, pr.StatementElement):
|
||||||
call = arr.parent
|
call = arr.parent
|
||||||
while isinstance(call.parent, pr.Call):
|
while isinstance(call.parent, pr.StatementElement):
|
||||||
call = call.parent
|
call = call.parent
|
||||||
arr.parent.execution = None
|
arr.parent.execution = None
|
||||||
return call if isinstance(call, pr.Name) else None, index, False
|
return call if isinstance(call, pr.Call) else None, index, False
|
||||||
return None, 0, False
|
return None, 0, False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1214,7 +1214,11 @@ class Literal(StatementElement):
|
|||||||
return type(self.value).__name__
|
return type(self.value).__name__
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s: %s>" % (type(self).__name__, self.literal)
|
if is_py3k:
|
||||||
|
s = self.literal
|
||||||
|
else:
|
||||||
|
s = self.literal.encode('ascii', 'replace')
|
||||||
|
return "<%s: %s>" % (type(self).__name__, s)
|
||||||
|
|
||||||
|
|
||||||
class String(Literal):
|
class String(Literal):
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
a = ""
|
a = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user