[pypy-commit] pypy py3k: apply a workaround for test_13_genexp from default
pjenvey
noreply at buildbot.pypy.org
Fri Apr 5 01:18:47 CEST 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r63033:0b705246a80a
Date: 2013-04-04 16:14 -0700
http://bitbucket.org/pypy/pypy/changeset/0b705246a80a/
Log: apply a workaround for test_13_genexp from default
diff --git a/lib-python/3/test/test_sys_settrace.py b/lib-python/3/test/test_sys_settrace.py
--- a/lib-python/3/test/test_sys_settrace.py
+++ b/lib-python/3/test/test_sys_settrace.py
@@ -213,12 +213,17 @@
"finally"
def generator_example():
# any() will leave the generator before its end
- x = any(generator_function())
+ x = any(generator_function()); gc.collect()
# the following lines were not traced
for x in range(10):
y = x
+# On CPython, when the generator is decref'ed to zero, we see the trace
+# for the "finally:" portion. On PyPy, we don't see it before the next
+# garbage collection. That's why we put gc.collect() on the same line
+# above.
+
generator_example.events = ([(0, 'call'),
(2, 'line'),
(-6, 'call'),
@@ -323,17 +328,24 @@
self.run_test(tighterloop_example)
def test_13_genexp(self):
- self.run_test(generator_example)
- # issue1265: if the trace function contains a generator,
- # and if the traced function contains another generator
- # that is not completely exhausted, the trace stopped.
- # Worse: the 'finally' clause was not invoked.
- tracer = Tracer()
- sys.settrace(tracer.traceWithGenexp)
- generator_example()
- sys.settrace(None)
- self.compare_events(generator_example.__code__.co_firstlineno,
- tracer.events, generator_example.events)
+ if self.using_gc:
+ support.gc_collect()
+ gc.enable()
+ try:
+ self.run_test(generator_example)
+ # issue1265: if the trace function contains a generator,
+ # and if the traced function contains another generator
+ # that is not completely exhausted, the trace stopped.
+ # Worse: the 'finally' clause was not invoked.
+ tracer = Tracer()
+ sys.settrace(tracer.traceWithGenexp)
+ generator_example()
+ sys.settrace(None)
+ self.compare_events(generator_example.__code__.co_firstlineno,
+ tracer.events, generator_example.events)
+ finally:
+ if self.using_gc:
+ gc.disable()
def test_14_onliner_if(self):
def onliners():
More information about the pypy-commit
mailing list