From 7afe86bfba35328e39b146e3df3bc491cfa71a64 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 17 Dec 2010 01:23:45 +0100 Subject: [PATCH] moved 'nonlocal' generator test over to generator test module to make all nonlocal tests compile in Py2.4 --- tests/run/generators.pyx | 15 +++++++++++++++ tests/run/nonlocal_T490.pyx | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/run/generators.pyx b/tests/run/generators.pyx index f2243afc..13fc7a6c 100644 --- a/tests/run/generators.pyx +++ b/tests/run/generators.pyx @@ -187,3 +187,18 @@ class Foo(object): def simple(self, *args): for i in args: yield i + +def generator_nonlocal(): + """ + >>> g = generator_nonlocal() + >>> list(g(5)) + [2, 3, 4, 5, 6] + """ + def f(x): + def g(y): + nonlocal x + for i in range(y): + x += 1 + yield x + return g + return f(1) diff --git a/tests/run/nonlocal_T490.pyx b/tests/run/nonlocal_T490.pyx index eb7f6610..0a5a80df 100644 --- a/tests/run/nonlocal_T490.pyx +++ b/tests/run/nonlocal_T490.pyx @@ -139,21 +139,6 @@ def class_body(int x, y): z = x,y return c() -def generator(): - """ - >>> g = generator() - >>> list(g(5)) - [2, 3, 4, 5, 6] - """ - def f(x): - def g(y): - nonlocal x - for i in range(y): - x += 1 - yield x - return g - return f(1) - def nested_nonlocals(x): """ >>> g = nested_nonlocals(1) -- 2.26.2