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

Python 3.7 StopIteration becomes RuntimeError #577

Closed
chingc opened this issue Jun 29, 2018 · 4 comments
Closed

Python 3.7 StopIteration becomes RuntimeError #577

chingc opened this issue Jun 29, 2018 · 4 comments

Comments

@chingc
Copy link

chingc commented Jun 29, 2018

PEP 479, enabled for all code in Python 3.7, is causing astroid to fail.
https://docs.python.org/3/whatsnew/3.7.html#changes-in-python-behavior

Steps to reproduce

"""empty.py"""

import os
pylint empty.py
output
No config file found, using default configuration
Traceback (most recent call last):
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\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 "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\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 "c:\python37\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Cherry\.virtualenvs\test-0PsIO9xF\Scripts\pylint.exe\__main__.py", line 9, in <module>
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\lint.py", line 1347, in __init__
    linter.check(args)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\lint.py", line 768, in check
    self._do_check(files_or_modules)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\lint.py", line 901, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\lint.py", line 980, in check_astroid_module
    walker.walk(ast_node)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\utils.py", line 1014, in walk
    self.walk(child)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\utils.py", line 1011, in walk
    cb(astroid)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\pylint\checkers\variables.py", line 1245, in visit_import
    module = next(node.infer_name_module(parts[0]))
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\context.py", line 71, in cache_generator
    for result in generator:
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 89, in wrapped
    res = next(generator)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\inference.py", line 194, in infer_import
    yield self.do_import_module(name)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\mixins.py", line 119, in do_import_module
    relative_only=level and level >= 1)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\scoped_nodes.py", line 593, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\manager.py", line 154, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\manager.py", line 80, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\builder.py", line 153, in file_build
    return self._post_build(module, encoding)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\builder.py", line 173, in _post_build
    self.delayed_assattr(delayed)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\builder.py", line 232, in delayed_assattr
    for inferred in node.expr.infer():
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 89, in wrapped
    res = next(generator)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\context.py", line 71, in cache_generator
    for result in generator:
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 86, in wrapped
    generator = _func(node, context, **kwargs)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\inference.py", line 760, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\protocols.py", line 304, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == 'metaclass'
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\scoped_nodes.py", line 1650, in _class_type
    if _is_metaclass(klass):
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\scoped_nodes.py", line 1619, in _is_metaclass
    for baseobj in base.infer():
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 89, in wrapped
    res = next(generator)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\context.py", line 71, in cache_generator
    for result in generator:
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 86, in wrapped
    generator = _func(node, context, **kwargs)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\inference.py", line 219, in infer_import_from
    module = self.do_import_module()
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\mixins.py", line 119, in do_import_module
    relative_only=level and level >= 1)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\scoped_nodes.py", line 593, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\manager.py", line 154, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\manager.py", line 80, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\builder.py", line 153, in file_build
    return self._post_build(module, encoding)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\builder.py", line 173, in _post_build
    self.delayed_assattr(delayed)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\builder.py", line 232, in delayed_assattr
    for inferred in node.expr.infer():
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 89, in wrapped
    res = next(generator)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\context.py", line 71, in cache_generator
    for result in generator:
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\decorators.py", line 86, in wrapped
    generator = _func(node, context, **kwargs)
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\inference.py", line 760, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\protocols.py", line 304, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == 'metaclass'
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\scoped_nodes.py", line 1650, in _class_type
    if _is_metaclass(klass):
  File "c:\users\cherry\.virtualenvs\test-0psio9xf\lib\site-packages\astroid\scoped_nodes.py", line 1619, in _is_metaclass
    for baseobj in base.infer():
RuntimeError: generator raised StopIteration

pylint --version

No config file found, using default configuration
pylint 1.9.2,
astroid 1.6.5
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
@PCManticore
Copy link
Contributor

This is already fixed by astroid 2.0. you'll have to get it with pip install astroid pylint --pre -U as they are not released yet (I'll probably do it next week)

@chingc
Copy link
Author

chingc commented Jun 29, 2018

Thanks!

@eli-schwartz
Copy link

not released yet (I'll probably do it next week)

any ETA on this? Arch Linux is currently rebuilding the world to deploy python 3.7 and this is one of our blockers, it would be nice to have a new version instead of manually backporting this fix.

@eli-schwartz
Copy link

Actually ATM even master is not enough for me to successfully run tests, see #593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants