From 47fb329a008c42c2ef052d3ded458555ef828d45 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 25 Nov 2010 19:05:40 +0100 Subject: [PATCH] test case for ticket #600: scope of iterable in genexprs --- tests/bugs.txt | 1 + tests/run/genexpr_iterable_lookup_T600.pyx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/run/genexpr_iterable_lookup_T600.pyx diff --git a/tests/bugs.txt b/tests/bugs.txt index 32dee735..48211a70 100644 --- a/tests/bugs.txt +++ b/tests/bugs.txt @@ -18,6 +18,7 @@ closure_inside_cdef_T554 ipow_crash_T562 pure_mode_cmethod_inheritance_T583 list_comp_in_closure_T598 +genexpr_iterable_lookup_T600 # CPython regression tests that don't current work: pyregr.test_threadsignals diff --git a/tests/run/genexpr_iterable_lookup_T600.pyx b/tests/run/genexpr_iterable_lookup_T600.pyx new file mode 100644 index 00000000..37d6c9f5 --- /dev/null +++ b/tests/run/genexpr_iterable_lookup_T600.pyx @@ -0,0 +1,18 @@ + +cimport cython + +@cython.test_assert_path_exists('//ComprehensionNode') +@cython.test_fail_if_path_exists('//SimpleCallNode') +def list_genexpr_iterable_lookup(): + """ + >>> x = (0,1,2,3,4,5) + >>> [ x*2 for x in x if x % 2 == 0 ] # leaks in Py2 but finds the right 'x' + [0, 4, 8] + + >>> list_genexpr_iterable_lookup() + [0, 4, 8] + """ + x = (0,1,2,3,4,5) + result = list( x*2 for x in x if x % 2 == 0 ) + assert x == (0,1,2,3,4,5) + return result -- 2.26.2