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

AssertionError when root is not a module #2672

Open
correctmost opened this issue Jan 16, 2025 · 0 comments
Open

AssertionError when root is not a module #2672

correctmost opened this issue Jan 16, 2025 · 0 comments
Labels
Crash 💥 Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@correctmost
Copy link
Contributor

Description

The following code triggers an AssertionError in astroid:

a=eval.__get__(1).__gt__

@a
class c: ...

This bug was discovered by OSS-Fuzz:
https://issues.oss-fuzz.com/issues/389974978 (report not public yet)

Backtrace

Traceback (most recent call last):
  File "pylint/pylint/lint/pylinter.py", line 979, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/manager.py", line 167, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/builder.py", line 173, in _post_build
    module = self._manager.visit_transforms(module)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/manager.py", line 128, in visit_transforms
    return self._transform.visit(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 162, in visit
    return self._visit(node)
           ^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 84, in _visit
    visited = self._visit_generic(value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 112, in _visit_generic
    return [self._visit_generic(child) for child in node]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 112, in <listcomp>
    return [self._visit_generic(child) for child in node]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 119, in _visit_generic
    return self._visit(node)
           ^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 87, in _visit
    return self._transform(node)
           ^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/transforms.py", line 66, in _transform
    if predicate is None or predicate(node):
                            ^^^^^^^^^^^^^^^
  File "astroid/astroid/brain/brain_attrs.py", line 59, in is_decorated_with_attrs
    if inferred and inferred.root().name == "attr._next_gen":
                    ^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 334, in root
    assert isinstance(self, nodes.Module)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Similar issues

Version

@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

2 participants