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

Weird __slots__ manip causes pylint to crash #9814

Closed
DeveloperAnonymous opened this issue Jul 20, 2024 · 0 comments · Fixed by #9817
Closed

Weird __slots__ manip causes pylint to crash #9814

DeveloperAnonymous opened this issue Jul 20, 2024 · 0 comments · Fixed by #9817
Assignees
Labels
Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@DeveloperAnonymous
Copy link

DeveloperAnonymous commented Jul 20, 2024

Bug description

When parsing the following a.py:

class Test:
    __slots__ = ["a", "b", "c"]

class TestChild(Test):
    __slots__ += ["d", "e", "f"]

t = TestChild()

print(t.__slots__)

Command used

pylint a.py

Pylint output

pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\lint\pylinter.py", line 788, in _lint_file
    check_astroid_module(module)
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\lint\pylinter.py", line 1017, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\lint\pylinter.py", line 1069, in _check_astroid_module
    walker.walk(node)
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\utils\ast_walker.py", line 94, in walk
    self.walk(child)
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\utils\ast_walker.py", line 91, in walk
    callback(astroid)
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\checkers\classes\class_checker.py", line 879, in visit_classdef
    self._check_slots(node)
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\checkers\classes\class_checker.py", line 1492, in _check_slots
    for slots in node.ilookup("__slots__"):
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\astroid\bases.py", line 194, in _infer_stmts
    raise InferenceError(
astroid.exceptions.InferenceError: Inference failed for all members of [<AssignName.__slots__ l.5 at 0x14ef5196a20>].

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\lint\pylinter.py", line 752, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "c:\Users\Matth\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs\pylint\lint\pylinter.py", line 790, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

Expected behavior

No crash.

Pylint version

pylint 3.0.2
astroid 3.0.1
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]

OS / Environment

win32 (Windows)

@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jul 20, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.2.6 milestone Jul 20, 2024
@jacobtylerwalls jacobtylerwalls self-assigned this Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants