Skip to content

Crash ``AstroidError: IndexError: list index out of range'' #9945

@edreamleo

Description

@edreamleo

Bug description

Crash when running pylint on leo/core/leoGlobals.py and leo\core\leoAst.py.

The files are too long to give here. You can find them both at
https://github.com/leo-editor/leo-editor/blob/devel/leo/core.

All Leo files are covered by the MIT license.

Configuration

C:\Users\Dev\.leo\.pylintrc available upon request.

Command used

pylint leo\core\leoGlobals.py

Equivalent to:

python -m pylint --rcfile C:\Users\Dev\.leo\.pylintrc %*

Pylint output

Traceback (most recent call last):
  File "C:\Python\Python3.12\Lib\site-packages\pylint\lint\pylinter.py", line 788, in _lint_file
    check_astroid_module(module)
  File "C:\Python\Python3.12\Lib\site-packages\pylint\lint\pylinter.py", line 1017, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python3.12\Lib\site-packages\pylint\lint\pylinter.py", line 1069, in _check_astroid_module
    walker.walk(node)
  File "C:\Python\Python3.12\Lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
    self.walk(child)
  File "C:\Python\Python3.12\Lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
    self.walk(child)
  File "C:\Python\Python3.12\Lib\site-packages\pylint\utils\ast_walker.py", line 87, in walk
    callback(astroid)
  File "C:\Python\Python3.12\Lib\site-packages\pylint\checkers\classes\special_methods_checker.py", line 183, in visit_functiondef
    inferred = _safe_infer_call_result(node, node)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python3.12\Lib\site-packages\pylint\checkers\classes\special_methods_checker.py", line 42, in _safe_infer_call_result
    value = next(inferit)
            ^^^^^^^^^^^^^
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\scoped_nodes\scoped_nodes.py", line 1658, in infer_call_result
    yield from returnnode.value.infer(context)
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_ng.py", line 168, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4776, in _infer
    yield from self._infer_from_values(self.values, context)
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4787, in _infer_from_values
    for suffix in cls._infer_from_values(nodes[1:], context, **kwargs):
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4787, in _infer_from_values
    for suffix in cls._infer_from_values(nodes[1:], context, **kwargs):
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4787, in _infer_from_values
    for suffix in cls._infer_from_values(nodes[1:], context, **kwargs):
  [Previous line repeated 2 more times]
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4786, in _infer_from_values
    for prefix in nodes[0]._infer(context, **kwargs):
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4683, in _infer
    for format_spec in self.format_spec.infer(context, **kwargs):
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_ng.py", line 168, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4776, in _infer
    yield from self._infer_from_values(self.values, context)
  File "C:\Python\Python3.12\Lib\site-packages\astroid\nodes\node_classes.py", line 4786, in _infer_from_values
    for prefix in nodes[0]._infer(context, **kwargs):
                  ~~~~~^^^
IndexError: list index out of range

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

Traceback (most recent call last):
  File "C:\Python\Python3.12\Lib\site-packages\pylint\lint\pylinter.py", line 752, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "C:\Python\Python3.12\Lib\site-packages\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.3.0
astroid 3.3.3

OS / Environment

Windows 11 AMD64 (build 10.0.22631) SP0
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
PyQt version 6.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crash 💥A bug that makes pylint crashNeeds astroid updateNeeds an astroid update (probably a release too) before being mergable

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions