Skip to content

AttributeError: 'Lambda' object has no attribute 'bases' in exceptions checker #10106

@correctmost

Description

@correctmost

Bug description

Pylint crashes on this fuzzed code from pysource-codegen:

e = lambda x: 1, 2

try:
    pass
except e:
    pass

Configuration

Command used

pylint crash.py

Pylint output

Exception on node <Try l.3 at 0x7fea43cf8a10> in file 'pylint/crash.py'
Traceback (most recent call last):
  File "pylint/pylint/utils/ast_walker.py", line 87, in walk
    callback(astroid)
  File "pylint/pylint/checkers/exceptions.py", line 609, in visit_try
    self._check_catching_non_exception(handler, exception, part)
  File "pylint/pylint/checkers/exceptions.py", line 433, in _check_catching_non_exception
    if all(
       ^^^^
  File "pylint/pylint/checkers/exceptions.py", line 435, in <genexpr>
    and (utils.inherit_from_std_ex(node) or not utils.has_known_bases(node))
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pylint/pylint/checkers/utils.py", line 1471, in has_known_bases
    for base in klass.bases:
                ^^^^^^^^^^^
AttributeError: 'Lambda' object has no attribute 'bases'

Expected behavior

No crash

Pylint version

pylint: 55098c7
astroid: cae4388d75
Python 3.12.7

OS / Environment

Arch Linux

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    BackportedCrash 💥A bug that makes pylint crashNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions