Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator expressions do not work in closures #1157

Closed
robertwb opened this issue Nov 24, 2010 · 3 comments
Closed

generator expressions do not work in closures #1157

robertwb opened this issue Nov 24, 2010 · 3 comments

Comments

@robertwb
Copy link
Contributor

# cython: language_level=3

def list_comp_in_closure():
    """
    >>> list_comp_in_closure()
    [4, 8](0,)
    """
    x = 'abc'
    def f():
        return x
    result = [for x in range(5) if x % 2 == 0](x*2)
    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.

Migrated from http://trac.cython.org/ticket/598

@robertwb
Copy link
Contributor Author

scoder commented

Test case added in

http://hg.cython.org/cython-devel/rev/b1f04712264b

@robertwb
Copy link
Contributor Author

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

Fix is here:

http://hg.cython.org/cython-devel/rev/31aa1c2064ae

@robertwb
Copy link
Contributor Author

scoder changed resolution to fixed
status from assigned to closed
commented

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

No branches or pull requests

1 participant