From 8174b312b5d0cb5fe2e6f242521b5717fef40bff Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 18 Nov 2015 18:00:15 +0100 Subject: [PATCH] Fix: CompFor.nodes_to_execute didn't include the right nodes. Sometimes too many, sometimes too few. --- jedi/__main__.py | 2 ++ jedi/parser/tree.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/jedi/__main__.py b/jedi/__main__.py index 3f2d61c9..f2ee0477 100644 --- a/jedi/__main__.py +++ b/jedi/__main__.py @@ -32,6 +32,8 @@ def _start_linter(): print(error) except Exception: if '--pdb' in sys.argv: + import traceback + traceback.print_exc() import pdb pdb.post_mortem() else: diff --git a/jedi/parser/tree.py b/jedi/parser/tree.py index e59e4279..fa87203c 100644 --- a/jedi/parser/tree.py +++ b/jedi/parser/tree.py @@ -1462,4 +1462,14 @@ class CompFor(BaseNode): return _defined_names(self.children[1]) def nodes_to_execute(self, last_added=False): - return self.children[-1].nodes_to_execute() + last = self.children[-1] + if last.type == 'comp_if': + for node in last.children[-1].nodes_to_execute(): + yield node + last = self.children[-2] + elif last.type == 'comp_for': + for node in last.nodes_to_execute(): + yield node + last = self.children[-2] + for node in last.nodes_to_execute(): + yield node