Commit 7afe86bf authored by Stefan Behnel's avatar Stefan Behnel

moved 'nonlocal' generator test over to generator test module to make all...

moved 'nonlocal' generator test over to generator test module to make all nonlocal tests compile in Py2.4
parent 4f8e5b0a
...@@ -187,3 +187,18 @@ class Foo(object): ...@@ -187,3 +187,18 @@ class Foo(object):
def simple(self, *args): def simple(self, *args):
for i in args: for i in args:
yield i 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)
...@@ -139,21 +139,6 @@ def class_body(int x, y): ...@@ -139,21 +139,6 @@ def class_body(int x, y):
z = x,y z = x,y
return c() 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): def nested_nonlocals(x):
""" """
>>> g = nested_nonlocals(1) >>> g = nested_nonlocals(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment