]> granicus.if.org Git - python/commitdiff
Add an example of a generator->freevar->cell->generator reference-cycle that
authorThomas Wouters <thomas@python.org>
Tue, 28 Mar 2006 08:14:24 +0000 (08:14 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 28 Mar 2006 08:14:24 +0000 (08:14 +0000)
doesn't get cleaned up and thus leaks.

Lib/test/leakers/test_generator_cycle.py [new file with mode: 0644]

diff --git a/Lib/test/leakers/test_generator_cycle.py b/Lib/test/leakers/test_generator_cycle.py
new file mode 100644 (file)
index 0000000..d2fa72c
--- /dev/null
@@ -0,0 +1,11 @@
+
+# This leaks since the introduction of yield-expr and the use of generators
+# as coroutines, trunk revision 39239. The cycle-GC doesn't seem to pick up
+# the cycle, or decides it can't clean it up.
+
+def leak():
+    def gen():
+        while True:
+            yield g
+    g = gen()
+