mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +08:00
tests and error catching for double executions
This commit is contained in:
31
evaluate.py
31
evaluate.py
@@ -115,14 +115,17 @@ class Execution(Exec):
|
|||||||
else:
|
else:
|
||||||
# set the callback function to get the params
|
# set the callback function to get the params
|
||||||
self.base.param_cb = self.get_params
|
self.base.param_cb = self.get_params
|
||||||
ret = self.base.returns
|
# don't do this with exceptions, as usual, because some deeper
|
||||||
for s in ret:
|
# exceptions could be catched - and I wouldn't know what happened.
|
||||||
#temp, s.parent = s.parent, self
|
if hasattr(self.base, 'returns'):
|
||||||
stmts += follow_statement(s)
|
ret = self.base.returns
|
||||||
#s.parent = temp
|
for s in ret:
|
||||||
|
#temp, s.parent = s.parent, self
|
||||||
|
stmts += follow_statement(s)
|
||||||
|
#s.parent = temp
|
||||||
|
|
||||||
# reset the callback function on exit
|
# reset the callback function on exit
|
||||||
self.base.param_cb = None
|
self.base.param_cb = None
|
||||||
|
|
||||||
debug.dbg('exec stmts=', stmts, self.base, repr(self))
|
debug.dbg('exec stmts=', stmts, self.base, repr(self))
|
||||||
|
|
||||||
@@ -432,11 +435,15 @@ def follow_call(scope, call):
|
|||||||
else:
|
else:
|
||||||
# TODO add better care for int/unicode, now str/float are just used
|
# TODO add better care for int/unicode, now str/float are just used
|
||||||
# instead
|
# instead
|
||||||
not_name_part = not isinstance(current, parsing.NamePart)
|
if not isinstance(current, parsing.NamePart):
|
||||||
if not_name_part and current.type == parsing.Call.STRING:
|
if current.type == parsing.Call.STRING:
|
||||||
scopes = get_scopes_for_name(builtin.Builtin.scope, 'str')
|
scopes = get_scopes_for_name(builtin.Builtin.scope, 'str')
|
||||||
elif not_name_part and current.type == parsing.Call.NUMBER:
|
elif current.type == parsing.Call.NUMBER:
|
||||||
scopes = get_scopes_for_name(builtin.Builtin.scope, 'float')
|
scopes = get_scopes_for_name(builtin.Builtin.scope, 'float')
|
||||||
|
else:
|
||||||
|
debug.warning('unknown type:', current.type, current)
|
||||||
|
# make instances of those number/string objects
|
||||||
|
scopes = [Instance(s) for s in scopes]
|
||||||
else:
|
else:
|
||||||
scopes = get_scopes_for_name(scope, current, search_global=True)
|
scopes = get_scopes_for_name(scope, current, search_global=True)
|
||||||
result = strip_imports(scopes)
|
result = strip_imports(scopes)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ u1.real
|
|||||||
u1.upper
|
u1.upper
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# should fail
|
# should fail (return nothing)
|
||||||
# -----------------
|
# -----------------
|
||||||
(f, g) = (1,)
|
(f, g) = (1,)
|
||||||
#? ['imag']
|
#? ['imag']
|
||||||
|
|||||||
@@ -38,3 +38,9 @@ def variable_rename(param):
|
|||||||
|
|
||||||
#? ['imag']
|
#? ['imag']
|
||||||
variable_rename(1).imag
|
variable_rename(1).imag
|
||||||
|
|
||||||
|
# double execution -> shouldn't work (and throw no error)
|
||||||
|
#? []
|
||||||
|
variable_rename(list())().
|
||||||
|
#? []
|
||||||
|
variable_rename(1)().
|
||||||
|
|||||||
Reference in New Issue
Block a user