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

another pylint stopIteration Runtime Error #2683

Closed
jbaum-cmcrc opened this issue Jan 8, 2019 · 3 comments
Closed

another pylint stopIteration Runtime Error #2683

jbaum-cmcrc opened this issue Jan 8, 2019 · 3 comments
Assignees
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Milestone

Comments

@jbaum-cmcrc
Copy link

I'm seeing another "RuntimeError: generator raised StopIteration", similar to the already-fixed #2241.

Steps to reproduce

  1. Make a file with the following contents:
class Foo:
    def __init__(self):
        self.count = 5 

    def bar(self):
        records = []
        for _ in []:
            records += []
        records = records[:self.count]
        records.sort()
  1. Run pylint on the file

Current behavior

Throws exception:

************* Module pylint_bug
pylint_bug.py:1:0: C0111: Missing module docstring (missing-docstring)
pylint_bug.py:1:0: C0111: Missing class docstring (missing-docstring)
pylint_bug.py:5:4: C0102: Black listed name "bar" (blacklisted-name)
pylint_bug.py:5:4: C0111: Missing method docstring (missing-docstring)
Traceback (most recent call last):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/inference.py", line 382, in infer_subscript
    assigned = value.getitem(index_value, context)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/node_classes.py", line 3609, in getitem
    return _container_getitem(self, self.elts, index, context=context)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/node_classes.py", line 204, in _container_getitem
    index_slice = _infer_slice(index, context=context)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/node_classes.py", line 187, in _infer_slice
    upper = _slice_value(node.upper, context)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/node_classes.py", line 171, in _slice_value
    inferred = next(index.infer(context=context))
StopIteration

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

Traceback (most recent call last):
  File "/home/jbaum/qq/venv-37/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/__init__.py", line 20, in run_pylint
    Run(sys.argv[1:])
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 1608, in __init__
    linter.check(args)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 938, in check
    self._do_check(files_or_modules)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 1071, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 1154, in check_astroid_module
    walker.walk(ast_node)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  [Previous line repeated 1 more time]
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/utils.py", line 1266, in walk
    cb(astroid)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/checkers/typecheck.py", line 1035, in visit_call
    called = safe_infer(node.func)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/checkers/utils.py", line 1077, in safe_infer
    next(inferit)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 128, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/inference.py", line 290, in infer_attribute
    for owner in self.expr.infer(context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 128, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/bases.py", line 135, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 128, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/bases.py", line 135, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 128, in raise_if_nothing_inferred
    yield next(generator)
RuntimeError: generator raised StopIteration

Expected behavior

Normal pylint report.

pylint --version output

pylint 2.2.2
astroid 2.1.0
Python 3.7.1 (default, Oct 22 2018, 11:21:55)
[GCC 8.2.0]

@PCManticore PCManticore added Bug 🪲 Crash 💥 A bug that makes pylint crash labels Jan 8, 2019
@PCManticore
Copy link
Contributor

Thanks, I can confirm the bug.

@PCManticore PCManticore added this to the Next minor release milestone Jan 8, 2019
@PCManticore PCManticore self-assigned this Jan 8, 2019
@PCManticore
Copy link
Contributor

Thanks for the report @jbaum-cmcrc This does not reproduce any longer on the master branch of pylint using the latest astroid. I added a test to make sure we have a regression test in case the bug replicates in the future.

@jbaum-cmcrc
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

No branches or pull requests

2 participants