1
0
forked from VimPlug/jedi

fix issues with generator comprehensions used directly with a send() call or something similar

This commit is contained in:
Dave Halter
2014-06-10 00:56:51 +02:00
parent 9cffbef608
commit 081fa79d9b
2 changed files with 13 additions and 5 deletions

View File

@@ -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)

View File

@@ -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
# -----------------