aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2016-10-01 17:27:46 -0700
committerPhilip Jenvey <pjenvey@underboss.org>2016-10-01 17:27:46 -0700
commit04fc70bde40e51c436d058289a5252a813f9aedb (patch)
tree70f5979280ed50e968674d070618c5a7238df55f /pypy/objspace/std/test
parentcpython issue4806: Avoid masking TypeError when *-unpacking a generator (diff)
downloadpypy-04fc70bde40e51c436d058289a5252a813f9aedb.tar.gz
pypy-04fc70bde40e51c436d058289a5252a813f9aedb.tar.bz2
pypy-04fc70bde40e51c436d058289a5252a813f9aedb.zip
ensure reversed types always free their sequence when finished
Diffstat (limited to 'pypy/objspace/std/test')
-rw-r--r--pypy/objspace/std/test/test_iterobject.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/pypy/objspace/std/test/test_iterobject.py b/pypy/objspace/std/test/test_iterobject.py
index 135c00a44a..e19c67f337 100644
--- a/pypy/objspace/std/test/test_iterobject.py
+++ b/pypy/objspace/std/test/test_iterobject.py
@@ -90,6 +90,18 @@ class AppTest_IterObject(object):
raises(TypeError, len, reversed(iterable))
del sys.modules['collections']
+ def test_reversed_frees_empty(self):
+ import gc
+ for typ in list, unicode:
+ free = [False]
+ class U(typ):
+ def __del__(self):
+ free[0] = True
+ r = reversed(U())
+ raises(StopIteration, next, r)
+ gc.collect(); gc.collect(); gc.collect()
+ assert free[0]
+
def test_no_len_on_set_iter(self):
iterable = set([1,2,3,4])
raises(TypeError, len, iter(iterable))