Anonymous avatar Anonymous committed f2f6586

Fixes a crash when an __init__ method in a base class has been created by assignment rather than direct function definition. Closes #110853

Comments (0)

Files changed (4)

 ====================
 
 --
+    * #110853: Fix a crash when an __init__ method in a base class has been
+      created by assignment rather than direct function definition. (patch by
+      Torsten Marek)
+
     * #110838: fix pylint-gui crash when include-ids is activated (patch by
       Omega Weapon)
 
     * #110839: bind <F5> to Run button in pylint-gui
 
 
---
+2012-10-05  --  0.26.0
     * #106534: add --ignore-imports option to code similarity checking
       and 'symilar' command line tool (patch by Ry4an Brase)
 

checkers/classes.py

     to_call = {}
     for base_node in klass_node.ancestors(recurs=False):
         try:
-            to_call[base_node] = base_node.local_attr(method)[-1]
-        except astng.NotFoundError:
+            to_call[base_node] = base_node.igetattr(method).next()
+        except astng.InferenceError:
             continue
     return to_call
 

test/input/func_w0231.py

     def __init__(self):
         super(NewStyleB, self).__init__()
 
-
 class NoInit(object):
     """No __init__ defined"""
 
 
     def __init__(self, arg):
         self.arg = arg
+
+class NewStyleC(object):
+    """__init__ defined by assignemnt."""
+    def xx_init(self):
+        """Initializer."""
+        pass
+
+    __init__ = xx_init
+
+class AssignedInit(NewStyleC):
+    """No init called."""
+    def __init__(self):
+        self.arg = 0

test/messages/func_w0231.txt

 W: 19:CCCC: Class has no __init__ method
 W: 26:ZZZZ.__init__: __init__ method from base class 'BBBB' is not called
+W: 59:AssignedInit.__init__: __init__ method from base class 'NewStyleC' is not called
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.