-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
pylint-dev/astroid
#2968Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crash
Description
Consider the following:
from pdb import Pdb as StdlibPdb
class Pdb(StdlibPdb):
...
class PatchedPdb(Pdb):
...
if __name__ == '__main__':
import pdb
pdb.Pdb = PatchedPdb
pdb.main()This crashes, I presume due to bad circular inference with the __name__ == '__main__' block. Removing that section leads to no crash.
This is a simplified reproducer, the original sketch code is below. Note IPython has a long Pdb inheritance, with one of the modules containing a __main__ block as in the reproducer above, so sadly it's not feasible to change/remove that section.
from IPython.terminal.debugger import TerminalPdb
class Spam(TerminalPdb):
...Command used
pylint bug.pyPylint output
Traceback (most recent call last):
File ".../site-packages/pylint/lint/pylinter.py", line 821, in _lint_file
check_astroid_module(module)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File ".../site-packages/pylint/lint/pylinter.py", line 1053, in check_astroid_module
retval = self._check_astroid_module(
ast_node, walker, rawcheckers, tokencheckers
)
File ".../site-packages/pylint/lint/pylinter.py", line 1105, in _check_astroid_module
walker.walk(node)
~~~~~~~~~~~^^^^^^
File ".../site-packages/pylint/utils/ast_walker.py", line 90, in walk
self.walk(child)
~~~~~~~~~^^^^^^^
File ".../site-packages/pylint/utils/ast_walker.py", line 87, in walk
callback(astroid)
~~~~~~~~^^^^^^^^^
File ".../site-packages/pylint/checkers/classes/class_checker.py", line 879, in visit_classdef
self._check_bases_classes(node)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File ".../site-packages/pylint/checkers/classes/class_checker.py", line 2186, in _check_bases_classes
unimplemented_abstract_methods(node, is_abstract).items(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File ".../site-packages/pylint/checkers/utils.py", line 954, in unimplemented_abstract_methods
mro = reversed(node.mro())
~~~~~~~~^^
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2863, in mro
return self._compute_mro(context=context)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2847, in _compute_mro
mro = base._compute_mro(context=context)
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2847, in _compute_mro
mro = base._compute_mro(context=context)
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2847, in _compute_mro
mro = base._compute_mro(context=context)
[Previous line repeated 979 more times]
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2841, in _compute_mro
inferred_bases = list(self._inferred_bases(context=context))
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2825, in _inferred_bases
baseobj = _infer_last(stmt, context)
File ".../site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 181, in _infer_last
for b in arg.infer(context=context.clone()):
~~~~~~~~~~~~~^^
File ".../site-packages/astroid/context.py", line 131, in clone
clone = InferenceContext(self.path.copy(), nodes_inferred=self._nodes_inferred)
RecursionError: maximum recursion depth exceeded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../site-packages/pylint/lint/pylinter.py", line 784, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../site-packages/pylint/lint/pylinter.py", line 823, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidErrorExpected behavior
No crash.
Pylint version
pylint 4.0.4
astroid 4.0.3
Python 3.14.2 (main, Dec 5 2025, 16:49:16) [Clang 17.0.0 (clang-1700.4.4.1)]OS / Environment
darwin (Darwin)
Additional dependencies
None.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crash