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
- gh-150700: Fix class-scope inline comprehensions when nested scopes reference
__class__and friends #150735 - [3.15] gh-150700: Fix class-scope inline comprehensions when nested scopes reference
__class__and friends (GH-150735) #151211 - [3.14] gh-150700: Fix class-scope inline comprehensions when nested scopes reference
__class__and friends (GH-150735) #151212