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

Crash Building error when trying to create ast representation of module 'test' #8334

Closed
torarvid opened this issue Feb 24, 2023 · 4 comments
Closed
Labels
Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable python 3.11
Milestone

Comments

@torarvid
Copy link

Bug description

When parsing the following file:

try:
    raise ExceptionGroup("test", [ValueError("value error")])
except* ValueError:
    print("hello")

pylint crashed with a AstroidBuildingError and with the following stacktrace:

Traceback (most recent call last):
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1026, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/manager.py", line 124, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/rebuilder.py", line 254, in <listcomp>
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/rebuilder.py", line 603, in visit
    visit_method = getattr(self, visit_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TreeRebuilder' object has no attribute 'visit_trystar'

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

Traceback (most recent call last):
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 718, in _get_asts
    ast_per_fileitem[fileitem] = self.get_ast(
                                 ^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1048, in get_ast
    raise astroid.AstroidBuildingError(
astroid.exceptions.AstroidBuildingError: Building error when trying to create ast representation of module 'test'

Configuration

No response

Command used

pylint test.py

Pylint output

pylint does not have any successful output, just a crash report (which I copy-pasted into the bug description above). For completeness, I'll paste the raw output here as well:


Traceback (most recent call last):
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1026, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/manager.py", line 124, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/rebuilder.py", line 254, in <listcomp>
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tor/oda/trex/.venv/lib/python3.11/site-packages/astroid/rebuilder.py", line 603, in visit
    visit_method = getattr(self, visit_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TreeRebuilder' object has no attribute 'visit_trystar'
************* Module test
test.py:1:0: F0002: test.py: Fatal error while checking 'test.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/tor/Library/Caches/pylint/pylint-crash-2023-02-24-12-49-59.txt'. (astroid-error)

Expected behavior

No crash expected

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.11.1 (main, Jan 10 2023, 15:10:23) [Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

macOS. uname -v yields
Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64

Additional dependencies

No response

@torarvid torarvid added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 24, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.3 milestone Feb 24, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash python 3.11 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 24, 2023
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue, this will be fixed by pylint-dev/astroid#2028

@Pierre-Sassoulas Pierre-Sassoulas added the Needs astroid update Needs an astroid update (probably a release too) before being mergable label Feb 24, 2023
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.16.3, 2.16.4 Mar 2, 2023
@jacobtylerwalls
Copy link
Member

I think we should land this in 2.17 as it needs a new minor version of astroid. No need to do more 2.16.x patch releases.

@Pierre-Sassoulas
Copy link
Member

Sounds good I wanted to do a small release with 2.17.0 anyway.

@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.16.4, 2.17.0, 3.0.0 Mar 3, 2023
@Pierre-Sassoulas
Copy link
Member

Fixed with #8387

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable python 3.11
Projects
None yet
Development

No branches or pull requests

3 participants