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 running pylint from the command line #9631

Closed
drawal1 opened this issue May 15, 2024 · 2 comments
Closed

Crash running pylint from the command line #9631

drawal1 opened this issue May 15, 2024 · 2 comments
Labels
Crash 💥 A bug that makes pylint crash Duplicate 🐫 Duplicate of an already existing issue Needs astroid update Needs an astroid update (probably a release too) before being mergable
Milestone

Comments

@drawal1
Copy link

drawal1 commented May 15, 2024

When parsing the py file

Command used

pylint a.py

Pylint output

pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 90, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 44, in wrapped
    if context.push(node):
       ^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/checkers/utils.py", line 1370, in safe_infer
    for inferred in infer_gen:
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 170, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 103, in inner
    yield from generator
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 49, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 170, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 103, in inner
    yield from generator
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 49, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 170, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 103, in inner
    yield from generator
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 49, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/node_classes.py", line 1764, in _infer
    yield from callee.infer_call_result(
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/bases.py", line 329, in infer_call_result
    for res in node.infer_call_result(caller, context):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/bases.py", line 329, in infer_call_result
    for res in node.infer_call_result(caller, context):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/bases.py", line 329, in infer_call_result
    for res in node.infer_call_result(caller, context):
  [Previous line repeated 951 more times]
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/bases.py", line 326, in infer_call_result
    for node in self._proxied.igetattr("__call__", context):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2524, in igetattr
    inferred._proxied.getattr("__get__", context)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2428, in getattr
    values += self._metaclass_lookup_attribute(name, context)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2452, in _metaclass_lookup_attribute
    attrs.update(set(cls_attributes))
                 ^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2459, in _get_attribute_from_metaclass
    attrs = cls.getattr(name, context=context, class_context=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2428, in getattr
    values += self._metaclass_lookup_attribute(name, context)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2448, in _metaclass_lookup_attribute
    metaclass = self.metaclass(context=context)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2740, in metaclass
    return self._find_metaclass(context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2720, in _find_metaclass
    klass = self.declared_metaclass(context=context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2692, in declared_metaclass
    for baseobj in base.infer(context=context):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 170, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/astroid/decorators.py", line 99, in inner
    raise InferenceError(
          ^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

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

Traceback (most recent call last):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 787, in _lint_file
    check_astroid_module(module)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1016, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1068, in _check_astroid_module
    walker.walk(node)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  [Previous line repeated 1 more time]
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/checkers/deprecated.py", line 94, in visit_attribute
    self.check_deprecated_attribute(node)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/checkers/deprecated.py", line 215, in check_deprecated_attribute
    inferred_expr = safe_infer(node.expr)
                    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/checkers/utils.py", line 1392, in safe_infer
    raise AstroidError from e
astroid.exceptions.AstroidError

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

Traceback (most recent call last):
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 751, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "/home/drawal/miniconda3/envs/xray/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 789, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

Expected behavior

No crash.

Pylint version

pylint 3.1.0
astroid 3.1.0
Python 3.11.8 (main, Feb 26 2024, 21:39:34) [GCC 11.2.0]

OS / Environment

linux (Linux)

@Pierre-Sassoulas Pierre-Sassoulas added the Crash 💥 A bug that makes pylint crash label May 15, 2024
@Pierre-Sassoulas
Copy link
Member

Will be fixed in astroid 3.2.1 from pylint-dev/astroid#2432, we need to release that in pylint.

@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.2.1 milestone May 15, 2024
@Pierre-Sassoulas Pierre-Sassoulas added the Needs astroid update Needs an astroid update (probably a release too) before being mergable label May 15, 2024
@jacobtylerwalls
Copy link
Member

Duplicate of #9139

@jacobtylerwalls jacobtylerwalls marked this as a duplicate of #9139 May 15, 2024
@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@jacobtylerwalls jacobtylerwalls added the Duplicate 🐫 Duplicate of an already existing issue label May 15, 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 Duplicate 🐫 Duplicate of an already existing issue Needs astroid update Needs an astroid update (probably a release too) before being mergable
Projects
None yet
Development

No branches or pull requests

3 participants