Commits

Anonymous committed bd22278

don't crash on AttributeError during attribute analysis

fixes issue #15
thanks Fazlul Shahriar for reporting

Comments (0)

Files changed (2)

rope/base/builtins.py

     for name in dir(obj):
         if name == 'None':
             continue
-        child = getattr(obj, name)
+        try:
+            child = getattr(obj, name)
+        except AttributeError:
+            # descriptors are allowed to raise AttributeError
+            # even if they are in dir()
+            continue
         pyobject = None
         if inspect.isclass(child):
             pyobject = BuiltinClass(child, {}, parent=parent)

ropetest/builtinstest.py

         self.mod.write(src)
         self.project.pycore.analyze_module(self.mod)
 
+    def test_abstractmethods_attribute(self):
+        # see http://bugs.python.org/issue10006 for details
+        src = 'class SubType(type): pass\nsubtype = SubType()\n'
+        self.mod.write(src)
+        self.project.pycore.analyze_module(self.mod)
+
 
 class BuiltinModulesTest(unittest.TestCase):