summaryrefslogtreecommitdiff
path: root/astroid
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-06-04 21:17:15 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2016-06-04 21:17:15 +0100
commit16d24126772d0da3d7e71690b731fff79ee50c99 (patch)
tree1cb35aa713374d1003fd4a5f899bd8c7733fe88c /astroid
parent671f8902992813687c4646fee33cf4666a108056 (diff)
downloadastroid-git-16d24126772d0da3d7e71690b731fff79ee50c99.tar.gz
Don't restrict building of builtin type's member if they are already in special_attributes
The introduction of the special attribute models led to an interesting bug, where some of the members of the builtin type were not added into it, since they were already defined at the level of the special_attributes. The latter is just a declaration of what attributes a type can have, usually leading to introspecting the type itself for retrieving the value of the special attribute.
Diffstat (limited to 'astroid')
-rw-r--r--astroid/interpreter/objectmodel.py4
-rw-r--r--astroid/raw_building.py2
-rw-r--r--astroid/tests/unittest_scoped_nodes.py1
3 files changed, 3 insertions, 4 deletions
diff --git a/astroid/interpreter/objectmodel.py b/astroid/interpreter/objectmodel.py
index 721127dc..47ca442c 100644
--- a/astroid/interpreter/objectmodel.py
+++ b/astroid/interpreter/objectmodel.py
@@ -491,8 +491,8 @@ class GeneratorModel(FunctionModel):
for name, values in generator.locals.items():
method = values[0]
patched = lambda self, meth=method: meth
-
- setattr(type(cls), 'py' + name, property(patched))
+ if not hasattr(type(cls), 'py' + name):
+ setattr(type(cls), 'py' + name, property(patched))
return cls
diff --git a/astroid/raw_building.py b/astroid/raw_building.py
index eb81cfb8..b0746aeb 100644
--- a/astroid/raw_building.py
+++ b/astroid/raw_building.py
@@ -256,7 +256,7 @@ def ast_from_class(cls, built_objects, module, name=None, parent=None):
bases = [node_classes.Name(name=b.__name__, parent=class_node)
for b in cls.__bases__]
body = [
- t for a in _classify_class_attrs(cls) if a.defining_class is cls and a.name not in scoped_nodes.ClassDef.special_attributes
+ t for a in _classify_class_attrs(cls) if a.defining_class is cls
for t in _ast_from_object(a.object, built_objects, module, a.name, parent=class_node)]
class_node.postinit(bases=bases, body=body, decorators=(),
newstyle=isinstance(cls, type))
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index 4294a844..d9583ddb 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -632,7 +632,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
self.assertRaises(AttributeInferenceError, inst.getattr, '__mro__')
self.assertRaises(AttributeInferenceError, inst.getattr, '__bases__')
self.assertRaises(AttributeInferenceError, inst.getattr, '__name__')
- self.assertRaises(AttributeInferenceError, inst.getattr, '__doc__')
self.assertRaises(AttributeInferenceError, inst.getattr, '__dict__')
def test_navigation(self):