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

Linked PRs

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesinterpreter-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