forked from VimPlug/jedi
fix issues with generator comprehensions used directly with a send() call or something similar
This commit is contained in:
@@ -181,13 +181,13 @@ class Evaluator(object):
|
||||
if pr.Array.is_type(element, pr.Array.NOARRAY):
|
||||
try:
|
||||
lst_cmp = element[0].expression_list()[0]
|
||||
if not isinstance(lst_cmp, pr.ListComprehension):
|
||||
raise IndexError
|
||||
except IndexError:
|
||||
pass
|
||||
r = list(itertools.chain.from_iterable(self.eval_statement(s)
|
||||
for s in element))
|
||||
else:
|
||||
if isinstance(lst_cmp, pr.ListComprehension):
|
||||
return [iterable.GeneratorComprehension(self, lst_cmp)]
|
||||
r = list(itertools.chain.from_iterable(self.eval_statement(s)
|
||||
for s in element))
|
||||
r = [iterable.GeneratorComprehension(self, lst_cmp)]
|
||||
call_path = element.generate_call_path()
|
||||
next(call_path, None) # the first one has been used already
|
||||
return self.follow_path(call_path, r, element.parent)
|
||||
|
||||
@@ -184,6 +184,14 @@ next(gen)
|
||||
#?
|
||||
gen[0]
|
||||
|
||||
gen = (a for arr in [[1.0]] for a in arr)
|
||||
#? float()
|
||||
next(gen)
|
||||
|
||||
#? int()
|
||||
(i for i in (1,)).send()
|
||||
|
||||
|
||||
# -----------------
|
||||
# ternary operator
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user