diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-05-05 16:59:22 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-05-05 16:59:22 +0300 |
commit | b583706f5836d507fb4fd692a4e74fe72f97724e (patch) | |
tree | c6e9d087063ef53222d7e563b57456ab510a9569 | |
parent | f44c9a1cdcf3c9983a712672e0342cb8dd489f7a (diff) | |
parent | b323833f58b9216c4d2432f33c61f0c852483df1 (diff) | |
download | pylint-b583706f5836d507fb4fd692a4e74fe72f97724e.tar.gz |
Merged in PCManticore/pylint/issue234 (pull request #112)
Fix a potential AttributeError when checking for constructor arguments. Closes issue #234.
-rw-r--r-- | checkers/typecheck.py | 2 | ||||
-rw-r--r-- | test/input/func_arguments.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/checkers/typecheck.py b/checkers/typecheck.py index 4cb406f..79774de 100644 --- a/checkers/typecheck.py +++ b/checkers/typecheck.py @@ -98,7 +98,7 @@ def _determine_callable(callable_obj): except astroid.NotFoundError: new = None - if not new or new.parent.name == 'object': + if not new or new.parent.scope().name == 'object': try: # Use the last definition of __init__. callable_obj = callable_obj.local_attr('__init__')[-1] diff --git a/test/input/func_arguments.py b/test/input/func_arguments.py index 1c27ef2..b607699 100644 --- a/test/input/func_arguments.py +++ b/test/input/func_arguments.py @@ -81,3 +81,20 @@ def method_tests(): demo.decorated_method() DemoClass.decorated_method(demo) +# Test a regression (issue #234) +import sys + +# pylint: disable=too-few-public-methods +class Text(object): + """ Regression """ + + if sys.version_info > (3,): + def __new__(cls): + """ empty """ + return object.__new__(cls) + else: + def __new__(cls): + """ empty """ + return object.__new__(cls) + +Text() |