Skip to content

"AttributeError: 'AssignAttr' object has no attribute 'name'" with starred expression #2646

Open
@correctmost

Description

@correctmost

Description

Astroid crashes on the following fuzzed code from pysource-codegen:

class c:
    a[t]

for *o.attr, (*t,) in ():
    pass

Backtrace

Exception on node <Subscript l.2 at 0x7bc5a43f8ad0> in file 'pylint/crash.py'
Traceback (most recent call last):
  File "pylint/pylint/checkers/utils.py", line 1365, in safe_infer
    value = next(infer_gen)
            ^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 167, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 86, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 49, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 167, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 86, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 49, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_classes.py", line 457, in _infer
    stmts = list(self.assigned_stmts(context=context))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 69, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "astroid/astroid/protocols.py", line 817, in starred_assigned_stmts
    _determine_starred_iteration_lookups(self, target, lookups)
  File "astroid/astroid/protocols.py", line 707, in _determine_starred_iteration_lookups
    and element.value.name == starred.value.name
        ^^^^^^^^^^^^^^^^^^
AttributeError: 'AssignAttr' object has no attribute 'name'

Version

cae4388

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crash 💥Needs PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions