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

addition of ast.Constant type makes astroid crash on import when using current CPython master (which will become 3.8) #617

Closed
njsmith opened this issue Sep 30, 2018 · 3 comments · Fixed by #616

Comments

@njsmith
Copy link

njsmith commented Sep 30, 2018

It looks like the merge of python/cpython#9445 broke astroid on CPython 3.8 pre-releases:

../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/trio/tests/test_exports.py:9: in <module>
    from pylint.lint import PyLinter
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/pylint/lint.py:75: in <module>
    import astroid
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/__init__.py:156: in <module>
    __import__(module[:-3])
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/brain/brain_builtin_inference.py:103: in <module>
    extend_builtins({'bytes': partial(_extend_str, rvalue="b''"),
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/brain/brain_builtin_inference.py:99: in extend_builtins
    transform(builtin_ast[class_name])
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/brain/brain_builtin_inference.py:84: in _extend_str
    fake = AstroidBuilder(MANAGER).string_build(code)['whatever']
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/builder.py:132: in string_build
    module = self._data_build(data, modname, path)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/builder.py:173: in _data_build
    module = builder.visit_module(node, modname, node_file, package)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:162: in visit_module
    newnode.postinit([self.visit(child, newnode) for child in node.body])
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:162: in <listcomp>
    newnode.postinit([self.visit(child, newnode) for child in node.body])
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:174: in visit
    return visit_method(node, parent)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:954: in visit_classdef
    return super(TreeRebuilder3, self).visit_classdef(node, parent,
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:394: in visit_classdef
    [self.visit(child, newnode)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:394: in <listcomp>
    [self.visit(child, newnode)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:174: in visit
    return visit_method(node, parent)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:576: in visit_functiondef
    return self._visit_functiondef(nodes.FunctionDef, node, parent)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:566: in _visit_functiondef
    body=[self.visit(child, newnode) for child in node.body],
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:566: in <listcomp>
    body=[self.visit(child, newnode) for child in node.body],
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:174: in visit
    return visit_method(node, parent)
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:741: in visit_return
    newnode.postinit(self.visit(node.value, newnode))
../../../../virtualenv/python3.8-dev/lib/python3.8/site-packages/astroid/rebuilder.py:172: in visit
    visit_method = getattr(self, visit_name)
E   AttributeError: 'TreeRebuilder3' object has no attribute 'visit_constant'

(See: https://travis-ci.org/python-trio/trio/jobs/435176057)

@njsmith njsmith changed the title addition of ast.Constant type on makes astroid crash on import when using current CPython master (which will become 3.8) addition of ast.Constant type makes astroid crash on import when using current CPython master (which will become 3.8) Sep 30, 2018
@njsmith
Copy link
Author

njsmith commented Sep 30, 2018

Looking more closely at bpo-32892, it looks like ast.Constant was actually added in 3.6, so it would be good to define visit_constant in any case. What changed in that PR is that the compiler now generates it in (many) more cases.

njsmith added a commit to njsmith/trio that referenced this issue Sep 30, 2018
This is currently causing the tests to crash. See:

    pylint-dev/astroid#617
njsmith added a commit to njsmith/trio that referenced this issue Sep 30, 2018
This is currently causing the tests to crash. See:

    pylint-dev/astroid#617
@serhiy-storchaka
Copy link
Contributor

And #616 should fix this issue.

@PCManticore
Copy link
Contributor

Should be fixed in master, going to create a dev release shortly. Thank you both for fixing this!

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

Successfully merging a pull request may close this issue.

3 participants