diff options
author | cpopa <devnull@localhost> | 2014-08-23 10:22:07 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-08-23 10:22:07 +0300 |
commit | 38af5b8b4a021633f4ef51258f9326f667860f9c (patch) | |
tree | dfe3a325aa710db8619a607168a082f53172747c | |
parent | 89aeb11ab83422f28ab2f894599bffb28a33ae51 (diff) | |
download | pylint-38af5b8b4a021633f4ef51258f9326f667860f9c.tar.gz |
Fix a crash which ocurred while checking for 'method-hidden', when the parent frame was something different than a function.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | checkers/classes.py | 3 | ||||
-rw-r--r-- | test/functional/regression_missing_module_type.py | 18 | ||||
-rw-r--r-- | test/functional/regression_missing_module_type.txt | 0 |
4 files changed, 23 insertions, 1 deletions
@@ -83,6 +83,9 @@ ChangeLog for Pylint * 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 diff --git a/checkers/classes.py b/checkers/classes.py index d9ebd8d..aa05558 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -377,7 +377,8 @@ a metaclass class method.'} 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())): diff --git a/test/functional/regression_missing_module_type.py b/test/functional/regression_missing_module_type.py new file mode 100644 index 0000000..fea4f5a --- /dev/null +++ b/test/functional/regression_missing_module_type.py @@ -0,0 +1,18 @@ +""" 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
diff --git a/test/functional/regression_missing_module_type.txt b/test/functional/regression_missing_module_type.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/functional/regression_missing_module_type.txt |