Skip to content

Class-scope comprehension with lambda raises SystemError #150700

@steve-s

Description

@steve-s

Bug report

Bug description:

class D:
    vals = [(lambda: __class__)() for _ in range(1)]

gives

SystemError: compiler_lookup_arg(name='__class__') with reftype=5 failed in D; freevars of code <lambda>: ('__class__',)

tested on main (f4bda4d) and on 3.12.8 (debug build). Issue #149806 looks related, but I tried that example on #149806 and it's not fixed by it.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions