summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generators.py
diff options
context:
space:
mode:
authorPhillip J. Eby <pje@telecommunity.com>2006-04-15 01:02:17 (GMT)
committerPhillip J. Eby <pje@telecommunity.com>2006-04-15 01:02:17 (GMT)
commit8ebb28df3a6e0bce240b6c2aa20d7aa5a4dfef39 (patch)
tree066424b3c1e37a639145e6453cb4f7d1b83b41e1 /Lib/test/test_generators.py
parent3cfea2dc987b90e637c4cbd5db5dc1f542e448b2 (diff)
downloadcpython-8ebb28df3a6e0bce240b6c2aa20d7aa5a4dfef39.zip
cpython-8ebb28df3a6e0bce240b6c2aa20d7aa5a4dfef39.tar.gz
cpython-8ebb28df3a6e0bce240b6c2aa20d7aa5a4dfef39.tar.bz2
Fix SF#1470508: crash in generator cycle finalization. There were two
problems: first, PyGen_NeedsFinalizing() had an off-by-one bug that prevented it from ever saying a generator didn't need finalizing, and second, frame objects cleared themselves in a way that caused their owning generator to think they were still executable, causing a double deallocation of objects on the value stack if there was still a loop on the block stack. This revision also removes some unnecessary close() operations from test_generators that are now appropriately handled by the cycle collector.
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r--Lib/test/test_generators.py7
1 files changed, 0 insertions, 7 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 3b7933e..b44d637 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -421,7 +421,6 @@ Subject: Re: PEP 255: Simple Generators
... self.name = name
... self.parent = None
... self.generator = self.generate()
-... self.close = self.generator.close
...
... def generate(self):
... while not self.parent:
@@ -484,8 +483,6 @@ A->A B->G C->A D->G E->G F->A G->G H->G I->A J->G K->A L->A M->G
merged A into G
A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
->>> for s in sets: s.close() # break cycles
-
"""
# Emacs turd '
@@ -593,7 +590,6 @@ arguments are iterable -- a LazyList is the same as a generator to times().
... def __init__(self, g):
... self.sofar = []
... self.fetch = g.next
-... self.close = g.close
...
... def __getitem__(self, i):
... sofar, fetch = self.sofar, self.fetch
@@ -624,8 +620,6 @@ efficient.
[200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384]
[400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675]
->>> m235.close()
-
Ye olde Fibonacci generator, LazyList style.
>>> def fibgen(a, b):
@@ -648,7 +642,6 @@ Ye olde Fibonacci generator, LazyList style.
>>> fib = LazyList(fibgen(1, 2))
>>> firstn(iter(fib), 17)
[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]
->>> fib.close()
Running after your tail with itertools.tee (new in version 2.4)