summaryrefslogtreecommitdiff
path: root/node_classes.py
diff options
context:
space:
mode:
authorSylvain Thénault <sylvain.thenault@logilab.fr>2011-07-08 12:08:07 +0200
committerSylvain Thénault <sylvain.thenault@logilab.fr>2011-07-08 12:08:07 +0200
commitf5b157f004d4f17d1cf81bcf1fa3f9860d9a92eb (patch)
tree1b796c49dc8ee1ec865627f2753daaab78299512 /node_classes.py
parent9d8800ca5703f364518240016aaed8e5434b2472 (diff)
downloadastroid-git-f5b157f004d4f17d1cf81bcf1fa3f9860d9a92eb.tar.gz
closes #70497: Crash on AttributeError: 'NoneType' object has no attribute '_infer_name' by fixing constant factory
Diffstat (limited to 'node_classes.py')
-rw-r--r--node_classes.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/node_classes.py b/node_classes.py
index 9bc6c568..2b50e0b9 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -885,6 +885,11 @@ _update_const_classes()
def const_factory(value):
"""return an astng node for a python value"""
+ # since const_factory is called to evaluate content of container (eg list,
+ # tuple), it may be called with some node as argument that should be left
+ # untouched
+ if isinstance(value, NodeNG):
+ return value
try:
return CONST_CLS[value.__class__](value)
except (KeyError, AttributeError):
@@ -894,4 +899,4 @@ def const_factory(value):
return Const(value)
node = EmptyNode()
node.object = value
- return None
+ return node