astroid icon indicating copy to clipboard operation
astroid copied to clipboard

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

Open correctmost opened this issue 1 year ago • 0 comments

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

cae4388d75a

correctmost avatar Dec 03 '24 09:12 correctmost