summaryrefslogtreecommitdiff
path: root/protocols.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-04-15 14:51:50 +0200
committerEmile Anclin <emile.anclin@logilab.fr>2010-04-15 14:51:50 +0200
commit6e2588643722fe48e81ae32016414aa023e68146 (patch)
tree549fe233ed9278371d7e4ab9c4a9e54e58d9a040 /protocols.py
parent38723d055dab450a4f7ed808614104d7d701fb99 (diff)
downloadastroid-git-6e2588643722fe48e81ae32016414aa023e68146.tar.gz
bugfix in _resolve_looppart : catch TypeError
calling getitem raises TypeError on unsubcriptable Const (int, ...)
Diffstat (limited to 'protocols.py')
-rw-r--r--protocols.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/protocols.py b/protocols.py
index e4e77917..fed9ae17 100644
--- a/protocols.py
+++ b/protocols.py
@@ -166,6 +166,8 @@ def _resolve_looppart(parts, asspath, context):
assigned = stmt.getitem(index, context)
except (AttributeError, IndexError):
continue
+ except TypeError, exc: # stmt is unsubscriptable Const
+ continue
if not asspath:
# we achieved to resolved the assignment path,
# don't infer the last part
@@ -176,7 +178,8 @@ def _resolve_looppart(parts, asspath, context):
# we are not yet on the last part of the path
# search on each possibly inferred value
try:
- for infered in _resolve_looppart(assigned.infer(context), asspath, context):
+ for infered in _resolve_looppart(assigned.infer(context),
+ asspath, context):
yield infered
except InferenceError:
break
@@ -189,8 +192,10 @@ def for_assigned_stmts(self, node, context=None, asspath=None):
for item in lst.elts:
yield item
else:
- for infered in _resolve_looppart(self.iter.infer(context), asspath, context):
+ for infered in _resolve_looppart(self.iter.infer(context),
+ asspath, context):
yield infered
+
nodes.For.assigned_stmts = raise_if_nothing_infered(for_assigned_stmts)
nodes.Comprehension.assigned_stmts = raise_if_nothing_infered(for_assigned_stmts)