Ticket #598 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

generator expressions do not work in closures

Reported by: scoder Owned by: scoder
Priority: major Milestone: 0.14
Component: Code Generation Keywords:


# cython: language_level=3

def list_comp_in_closure():
    >>> list_comp_in_closure()
    [0, 4, 8]
    x = 'abc'
    def f():
        return x
    result = [x*2 for x in range(5) if x % 2 == 0]
    assert x == 'abc' # don't leak in Py3 code
    assert f() == 'abc' # don't leak in Py3 code
    return result

generates invalid C code: the loop variable is defined in the closure struct but has a different name inside of the function code.

Change History

Changed 4 years ago by scoder

Changed 4 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned
  • milestone changed from wishlist to 0.13.1

Changed 4 years ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.