You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing another "RuntimeError: generator raised StopIteration", similar to the already-fixed #2241.
Steps to reproduce
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()
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
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.
I'm seeing another "RuntimeError: generator raised StopIteration", similar to the already-fixed #2241.
Steps to reproduce
Current behavior
Throws exception:
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]
The text was updated successfully, but these errors were encountered: