summaryrefslogtreecommitdiff
path: root/node_classes.py
diff options
context:
space:
mode:
authorFELD Boris <lothiraldan@gmail.com>2012-07-31 10:40:29 +0200
committerFELD Boris <lothiraldan@gmail.com>2012-07-31 10:40:29 +0200
commit383c87a2b3d918925891af30058ac0aefbd53842 (patch)
tree804197b484f9ebd8914781c0361bb7d8e98919ba /node_classes.py
parent6897d7a7662c799f5ce2f4828723ec5bb2b8409c (diff)
downloadastroid-383c87a2b3d918925891af30058ac0aefbd53842.tar.gz
Fix python 3 crash on importing from a non existing module. Closes #83749
Pb is actually silented in python 2 since YES objet are seen as iterable since next() is seen as a proper attribute (returning itself, see _Yes.__getattribute__), while it becomes a function in python 3.
Diffstat (limited to 'node_classes.py')
-rw-r--r--node_classes.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/node_classes.py b/node_classes.py
index 7b196af..3073535 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
# copyright 2003-2010 Sylvain Thenault, all rights reserved.
# contact mailto:thenault@gmail.com
@@ -39,13 +39,18 @@ def unpack_infer(stmt, context=None):
for infered_elt in unpack_infer(elt, context):
yield infered_elt
return
+ # if infered is a final node, return it and stop
infered = stmt.infer(context).next()
- if infered is stmt or infered is YES:
+ if infered is stmt:
yield infered
return
+ # else, infer recursivly, except YES object that should be returned as is
for infered in stmt.infer(context):
- for inf_inf in unpack_infer(infered, context):
- yield inf_inf
+ if infered is YES:
+ yield infered
+ else:
+ for inf_inf in unpack_infer(infered, context):
+ yield inf_inf
def are_exclusive(stmt1, stmt2, exceptions=None):