Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash 'Attribute' object has no attribute 'name' in _check_unused_private_variables due to access via self.__class__ #5261

Closed
graingert opened this issue Nov 5, 2021 · 3 comments · Fixed by #5262
Assignees
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Milestone

Comments

@graingert
Copy link
Contributor

When parsing the following file:

class Foo:
    __ham = 1

    def foo():
        print(self.__class__.__ham)

pylint crashed with a AttributeError and with the following stacktrace:

Traceback (most recent call last):
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1008, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1043, in _check_file
    check_astroid_module(ast_node)
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1180, in check_astroid_module
    retval = self._check_astroid_module(
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1227, in _check_astroid_module
    walker.walk(node)
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 78, in walk
    self.walk(child)
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 80, in walk
    callback(astroid)
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/checkers/classes.py", line 907, in leave_classdef
    self._check_unused_private_variables(node)
  File "/home/graingert/.local/pipx/.cache/1ea90594a10eda9/lib/python3.8/site-packages/pylint/checkers/classes.py", line 973, in _check_unused_private_variables
    and child.expr.name in ("self", "cls", node.name)
AttributeError: 'Attribute' object has no attribute 'name'
@graingert graingert changed the title Crash 'Attribute' object has no attribute 'name' (if possible, be more specific about what made pylint crash) Crash 'Attribute' object has no attribute 'name' in _check_unused_private_variables due to access via self.__class__ Nov 5, 2021
@graingert
Copy link
Contributor Author

@Pierre-Sassoulas Pierre-Sassoulas added Bug 🪲 Crash 💥 A bug that makes pylint crash labels Nov 5, 2021
@DanielNoord DanielNoord self-assigned this Nov 5, 2021
@DanielNoord DanielNoord added this to the 2.12.0 milestone Nov 5, 2021
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Nov 5, 2021
@DanielNoord
Copy link
Collaborator

Thanks for the report!

We should be able to ship a fix with 2.12 which I think will be published soon™.

@graingert
Copy link
Contributor Author

Thanks for the report!

We should be able to ship a fix with 2.12 which I think will be published soon™.

Thanks for this, Amazing speed in getting this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants