From: Stefan Behnel Date: Fri, 17 Dec 2010 00:23:45 +0000 (+0100) Subject: moved 'nonlocal' generator test over to generator test module to make all nonlocal... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7afe86bfba35328e39b146e3df3bc491cfa71a64;p=cython.git moved 'nonlocal' generator test over to generator test module to make all nonlocal tests compile in Py2.4 --- 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)