pylint-dev / astroid

A common base representation of python source code for pylint and other projects
https://pylint.readthedocs.io/projects/astroid/en/latest/
GNU Lesser General Public License v2.1
530 stars 275 forks source link

maximum recursion depth exceeded in __call__ #235

Closed pylint-bot closed 6 years ago

pylint-bot commented 9 years ago

Originally reported by: Adam Groszer (BitBucket: agroszer, GitHub: @agroszer?)


I created a repo to repro this:

https://github.com/agroszer/playground

After all setup is done, you run $ bin/pylint playground.scriptapi2, bang you should get:

************* Module playground.scriptapi2
C:  1, 0: Missing module docstring (missing-docstring)
C:  6, 0: Missing class docstring (missing-docstring)
E: 14,29: Instance of 'Number2Words' has no 'tens' member (no-member)
E: 18,56: Instance of 'Number2Words' has no 'scales' member (no-member)
Traceback (most recent call last):
  File "bin/pylint", line 58, in <module>
    run_pylint()
  File "/work/zopefix/playground/dep/pylint/pylint/__init__.py", line 23, in run_pylint
    Run(sys.argv[1:])
  File "/work/zopefix/playground/dep/pylint/pylint/lint.py", line 1315, in __init__
    linter.check(args)
  File "/work/zopefix/playground/dep/pylint/pylint/lint.py", line 734, in check
    self._do_check(files_or_modules)
  File "/work/zopefix/playground/dep/pylint/pylint/lint.py", line 865, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/work/zopefix/playground/dep/pylint/pylint/lint.py", line 945, in check_astroid_module
    walker.walk(ast_node)
  File "/work/zopefix/playground/dep/pylint/pylint/utils.py", line 936, in walk
    self.walk(child)
  File "/work/zopefix/playground/dep/pylint/pylint/utils.py", line 936, in walk
    self.walk(child)
  File "/work/zopefix/playground/dep/pylint/pylint/utils.py", line 936, in walk
    self.walk(child)
  File "/work/zopefix/playground/dep/pylint/pylint/utils.py", line 936, in walk
    self.walk(child)
  File "/work/zopefix/playground/dep/pylint/pylint/utils.py", line 933, in walk
    cb(astroid)
  File "/work/zopefix/playground/dep/pylint/pylint/checkers/typecheck.py", line 980, in visit_listcomp
    self._check_iterable(gen.iter, node)
  File "/work/zopefix/playground/dep/pylint/pylint/checkers/typecheck.py", line 945, in _check_iterable
    if _should_skip_iterable_check(node):
  File "/work/zopefix/playground/dep/pylint/pylint/checkers/typecheck.py", line 136, in _should_skip_iterable_check
    infered = helpers.safe_infer(node)
  File "/work/zopefix/playground/dep/astroid/astroid/helpers.py", line 113, in safe_infer
    next(inferit)
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/bases.py", line 98, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 338, in _filter_operation_errors
    for result in infer_callable(self, context):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 637, in _infer_augassign
    for rhs in self.value.infer(context=rhs_context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 111, in yes_if_nothing_inferred
    for node in func(*args, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 338, in _filter_operation_errors
    for result in infer_callable(self, context):
...
snip
...
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 114, in infer_call
    for inferred in callee.infer_call_result(self, callcontext):
  File "/work/zopefix/playground/dep/astroid/astroid/bases.py", line 206, in infer_call_result
    for res in node.infer_call_result(caller, context):
  File "/work/zopefix/playground/dep/astroid/astroid/scoped_nodes.py", line 948, in infer_call_result
    for inferred in returnnode.value.infer(context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/bases.py", line 98, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 338, in _filter_operation_errors
    for result in infer_callable(self, context):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 637, in _infer_augassign
    for rhs in self.value.infer(context=rhs_context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 111, in yes_if_nothing_inferred
    for node in func(*args, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 338, in _filter_operation_errors
    for result in infer_callable(self, context):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 591, in _infer_binop
    for lhs in left.infer(context=lhs_context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 121, in raise_if_nothing_inferred
    for node in func(*args, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 108, in infer_call
    for callee in self.func.infer(context):
  File "/work/zopefix/playground/dep/astroid/astroid/context.py", line 51, in cache_generator
    for result in generator:
  File "/work/zopefix/playground/dep/astroid/astroid/decorators.py", line 96, in wrapped
    for res in _func(node, context, **kwargs):
  File "/work/zopefix/playground/dep/astroid/astroid/inference.py", line 82, in infer_name
    frame, stmts = self.lookup(self.name)
  File "/work/zopefix/playground/dep/astroid/astroid/node_classes.py", line 652, in lookup
    return self.scope().scope_lookup(self, name)
RuntimeError: maximum recursion depth exceeded

(Sorry, can't find a better title, because I have no idea what causes it)


pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Thank you. Will look into it.

pylint-bot commented 9 years ago

Original comment by Adam Groszer (BitBucket: agroszer, GitHub: @agroszer?):


Any hints how could I work around that single failing method? Keep the most possible checks but avoid the exception?

pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Try to disable not-an-iterable and see if that works. I'm working on releasing the new version, without these crashes this week or next.

brycepg commented 6 years ago

I can no longer reproduce this example. I think this was another augassign recursion dupe. Closing for now.