Commits

Anonymous committed e9ae6b3

Fix a crash which ocurred while checking for 'method-hidden', when the parent frame was something different than a function.

Comments (0)

Files changed (4)

     * Add a new warning, 'boolean-datetime', emitted when an instance
       of 'datetime.time' is used in a boolean context. Closes issue #239.
 
+    * Fix a crash which ocurred while checking for 'method-hidden',
+      when the parent frame was something different than a function.
+
 
 2014-07-26  --  1.3.0
 

checkers/classes.py

         try:
             overridden = klass.instance_attr(node.name)[0] # XXX
             overridden_frame = overridden.frame()
-            if overridden_frame.type == 'method':
+            if (isinstance(overridden_frame, astroid.Function)
+                    and overridden_frame.type == 'method'):
                 overridden_frame = overridden_frame.parent.frame()
             if (isinstance(overridden_frame, Class)
                     and klass._is_subtype_of(overridden_frame.qname())):

test/functional/regression_missing_module_type.py

+""" Test for a regression found in
+https://bitbucket.org/logilab/astroid/issue/45/attributeerror-module-object-has-no#comment-11944673
+"""
+# pylint: disable=no-init, invalid-name, too-few-public-methods, redefined-outer-name
+def decor(trop):
+    """ decorator """
+    return trop
+
+class Foo:
+    """ Class """
+    @decor
+    def prop(self):
+        """ method """
+        return self
+
+if __name__ == '__main__':
+    trop = Foo()
+    trop.prop = 42

test/functional/regression_missing_module_type.txt

Empty file added.