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 'Call' object has no attribute 'name' when accessing a private class variable #5569

Closed
bugale opened this issue Dec 20, 2021 · 1 comment · Fixed by #5662
Closed

Crash 'Call' object has no attribute 'name' when accessing a private class variable #5569

bugale opened this issue Dec 20, 2021 · 1 comment · Fixed by #5662
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Milestone

Comments

@bugale
Copy link

bugale commented Dec 20, 2021

Bug description

Seems similar to #4638, but reproduces after its fix

When parsing the following file:

class A:
    @classmethod
    def b(cls) -> None:
        cls.__a = ''

    def a(self):
        type(self).__a

pylint crashed with a AttributeError and with the following stacktrace:

Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\site-packages\pylint\lint\pylinter.py", line 1034, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "C:\Program Files\Python39\lib\site-packages\pylint\lint\pylinter.py", line 1069, in _check_file
    check_astroid_module(ast_node)
  File "C:\Program Files\Python39\lib\site-packages\pylint\lint\pylinter.py", line 1203, in check_astroid_module
    retval = self._check_astroid_module(
  File "C:\Program Files\Python39\lib\site-packages\pylint\lint\pylinter.py", line 1250, in _check_astroid_module
    walker.walk(node)
  File "C:\Program Files\Python39\lib\site-packages\pylint\utils\ast_walker.py", line 75, in walk
    self.walk(child)
  File "C:\Program Files\Python39\lib\site-packages\pylint\utils\ast_walker.py", line 77, in walk
    callback(astroid)
  File "C:\Program Files\Python39\lib\site-packages\pylint\checkers\classes.py", line 901, in leave_classdef
    self._check_unused_private_attributes(node)
  File "C:\Program Files\Python39\lib\site-packages\pylint\checkers\classes.py", line 1008, in _check_unused_private_attributes
    and attribute.expr.name in {"cls", "self", node.name}
AttributeError: 'Call' object has no attribute 'name'

Configuration

No response

Command used

pylint bugale_test.py

Pylint output

Exception on node <ClassDef.A l.1 at 0x19bf0e5c820> in file 'C:\Users\bugaleb\Documents\GitHub\winagent\SmartViz\AutomationTests\bugale_test.py'
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\site-packages\pylint\utils\ast_walker.py", line 77, in walk
    callback(astroid)
  File "C:\Program Files\Python39\lib\site-packages\pylint\checkers\classes.py", line 901, in leave_classdef
    self._check_unused_private_attributes(node)
  File "C:\Program Files\Python39\lib\site-packages\pylint\checkers\classes.py", line 1008, in _check_unused_private_attributes
    and attribute.expr.name in {"cls", "self", node.name}
AttributeError: 'Call' object has no attribute 'name'
bugale_test.py:1:0: F0001: Fatal error while checking 'bugale_test.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\bugaleb\AppData\Local\pylint\pylint\Cache\pylint-crash-2021-12-21-00.txt'. (fatal)

Expected behavior

Not to crash

Pylint version

pylint 2.12.2
astroid 2.9.0
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]

OS / Environment

Windows 11

Additional dependencies

No response

@bugale bugale added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 20, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 20, 2021
@Pierre-Sassoulas
Copy link
Member

I can reproduce this with the latest main, thank you for opening the issue.

@Pierre-Sassoulas Pierre-Sassoulas added the Blocker 🙅 Blocks the next release label Dec 20, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Dec 20, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jan 10, 2022
Pierre-Sassoulas pushed a commit that referenced this issue Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Projects
None yet
2 participants