[code-quality] pylint traceback AttributeError: 'NoneType' object has no attribute 'scope'

Claudiu Popa pcmanticore at gmail.com
Tue Aug 19 19:47:12 CEST 2014


On Tue, Aug 19, 2014 at 7:10 PM, Mark E. Hamilton <mhamilt at sandia.gov> wrote:
> With this test script:
>
> % cat test_util.py
> #!/usr/bin/env python
> """Some docstring"""
> import sys
> if __name__ == '__main__':
>     """Another docstring."""
>     pass
>
> pylint throws this traceback:
>
>
> % pylint --rcfile=/dev/null test_util.py
> Traceback (most recent call last):
>   File "/projects/sierra/linux_rh6/install/Python/2.7/bin/pylint", line 9,
> in <module>
>     load_entry_point('pylint==1.3.0', 'console_scripts', 'pylint')()
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/__init__.py",
> line 21, in run_pylint
>     Run(sys.argv[1:])
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/lint.py",
> line 991, in __init__
>     linter.check(args)
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/lint.py",
> line 585, in check
>     self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/lint.py",
> line 662, in check_astroid_module
>     walker.walk(astroid)
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/utils.py",
> line 804, in walk
>     self.walk(child)
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/utils.py",
> line 804, in walk
>     self.walk(child)
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/utils.py",
> line 801, in walk
>     cb(astroid)
>   File
> "/projects/sierra/linux_rh6/install/Python/2.7/lib/python2.7/site-packages/pylint-1.3.0-py2.7.egg/pylint/checkers/base.py",
> line 558, in visit_discard
>     if (sibling.scope() is scope and
> AttributeError: 'NoneType' object has no attribute 'scope'
>
>
> Removing the second docstring (see below) resolves this error:
>
> % cat test_util.py
> #!/usr/bin/env python
> """Some docstring"""
> import sys
> if __name__ == '__main__':
>     # """Another docstring."""
>     pass
>


Hi, Mark.

Which version of astroid? I'm unable to replicate this using the
latest. Also, for these type of crashes, it's best to report them on
our bug tracker.
Thanks.


More information about the code-quality mailing list