Skip to content

Comprehension inlining: Bug if comprehension contains a lambda #104357

Description

@JelleZijlstra

Code sample:

def outer(x):
    return [lambda: x for x in range(x)]

print([f() for f in outer(2)])

On 3.11, this produces [1, 1] as expected.

But on current main, I get:

>>> [f() for f in outer(2)]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in outer
TypeError: 'cell' object cannot be interpreted as an integer

Almost certainly due to PEP 709 / #101441, cc @carljm.

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions