mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
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):
|
if pr.Array.is_type(element, pr.Array.NOARRAY):
|
||||||
try:
|
try:
|
||||||
lst_cmp = element[0].expression_list()[0]
|
lst_cmp = element[0].expression_list()[0]
|
||||||
|
if not isinstance(lst_cmp, pr.ListComprehension):
|
||||||
|
raise IndexError
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if isinstance(lst_cmp, pr.ListComprehension):
|
|
||||||
return [iterable.GeneratorComprehension(self, lst_cmp)]
|
|
||||||
r = list(itertools.chain.from_iterable(self.eval_statement(s)
|
r = list(itertools.chain.from_iterable(self.eval_statement(s)
|
||||||
for s in element))
|
for s in element))
|
||||||
|
else:
|
||||||
|
r = [iterable.GeneratorComprehension(self, lst_cmp)]
|
||||||
call_path = element.generate_call_path()
|
call_path = element.generate_call_path()
|
||||||
next(call_path, None) # the first one has been used already
|
next(call_path, None) # the first one has been used already
|
||||||
return self.follow_path(call_path, r, element.parent)
|
return self.follow_path(call_path, r, element.parent)
|
||||||
|
|||||||
@@ -184,6 +184,14 @@ next(gen)
|
|||||||
#?
|
#?
|
||||||
gen[0]
|
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
|
# ternary operator
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user