Pylint: RuntimeError when checked code includes Exception with its argument in Python 3.7

Created on 30 Jun 2018  路  1Comment  路  Source: PyCQA/pylint

Environment:

  • Ubuntu 18.04
  • Python 3.7
  • Pylint 1.9.2
  • Astroid 1.6.5

Here is the code.

# test_pylint.py
def f():
    raise Exception("Some message")  # Exception has its argument

And when you pylint test_pylint.py this error below happens.

No config file found, using default configuration
************* Module test_pylint
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Function name "f" doesn't conform to snake_case naming style (invalid-name)
C:  1, 0: Missing function docstring (missing-docstring)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 104, in wrapped
    raise StopIteration
StopIteration

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

Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/usr/local/lib/python3.7/site-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 1347, in __init__
    linter.check(args)
  File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 768, in check
    self._do_check(files_or_modules)
  File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 901, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 980, in check_astroid_module
    walker.walk(ast_node)
  File "/usr/local/lib/python3.7/site-packages/pylint/utils.py", line 1014, in walk
    self.walk(child)
  File "/usr/local/lib/python3.7/site-packages/pylint/utils.py", line 1014, in walk
    self.walk(child)
  File "/usr/local/lib/python3.7/site-packages/pylint/utils.py", line 1011, in walk
    cb(astroid)
  File "/usr/local/lib/python3.7/site-packages/pylint/checkers/exceptions.py", line 266, in visit_raise
    inferred_value = next(expr.infer())
  File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/usr/local/lib/python3.7/site-packages/astroid/inference.py", line 172, in infer_call
    for inferred in callee.infer_call_result(self, callcontext):
  File "/usr/local/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 1958, in infer_call_result
    if (self.is_subtype_of('%s.type' % (BUILTINS,), context)
  File "/usr/local/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 1916, in is_subtype_of
    for anc in self.ancestors(context=context):
  File "/usr/local/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2059, in ancestors
    context=context):
  File "/usr/local/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2046, in ancestors
    for baseobj in stmt.infer(context):
  File "/usr/local/lib/python3.7/site-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
RuntimeError: generator raised StopIteration

And please note that when checked this version of code, Pylint doesn't raise the error.

# test_pylint.py
def f():
    raise Exception  # No argument

pylint --version output

No config file found, using default configutation
pylint 1.9.2,
astroid 1.6.5
Python 3.7.0 (default, Jun 28 2018, 01:58:51)
[Clang 6.0.1 (branches/release_60)]

Most helpful comment

This is using Python 3.7. The current 1.9 release does not support it, you'll have to get a newer version with pip install pylint astroid --pre -U.

>All comments

This is using Python 3.7. The current 1.9 release does not support it, you'll have to get a newer version with pip install pylint astroid --pre -U.

Was this page helpful?
0 / 5 - 0 ratings