diff options
| -rw-r--r-- | bases.py | 1 | ||||
| -rw-r--r-- | node_classes.py | 4 |
2 files changed, 4 insertions, 1 deletions
@@ -342,6 +342,7 @@ class NodeNG(BaseClass): It represents a node of the new abstract syntax tree. """ is_statement = False + optional_assign = False # True for For (and for Comprehension if py <3.0) # attributes below are set by the builder module or by raw factories lineno = None fromlineno = None diff --git a/node_classes.py b/node_classes.py index 2b5d8fd1..b3fc1871 100644 --- a/node_classes.py +++ b/node_classes.py @@ -171,7 +171,7 @@ class LookupMixIn(BaseClass): if done: break - optional_assign = isinstance(ass_type, (For, Comprehension)) + optional_assign = ass_type.optional_assign if optional_assign and ass_type.parent_of(self): # we are inside a loop, loop var assigment is hidding previous # assigment @@ -406,6 +406,7 @@ class Comprehension(NodeNG): iter = None ifs = None + optional_assign = True def ass_type(self): return self @@ -569,6 +570,7 @@ class For(BlockRangeMixIn, StmtMixIn, AssignTypeMixin, NodeNG): body = None orelse = None + optional_assign = True def _blockstart_toline(self): return self.iter.tolineno |
