[pypy-commit] pypy gc-del: Various efforts to make this test pass --- but it was actually miswritten.
arigo
noreply at buildbot.pypy.org
Mon Mar 25 19:22:02 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: gc-del
Changeset: r62748:a1039dd12074
Date: 2013-03-25 19:21 +0100
http://bitbucket.org/pypy/pypy/changeset/a1039dd12074/
Log: Various efforts to make this test pass --- but it was actually
miswritten.
diff --git a/rpython/memory/gcwrapper.py b/rpython/memory/gcwrapper.py
--- a/rpython/memory/gcwrapper.py
+++ b/rpython/memory/gcwrapper.py
@@ -220,16 +220,16 @@
t = self.llinterp.typer.annotator.translator
DestructorAnalyzer(t).check_destructor(destrgraph)
- def ll_finalizer(addr, dummy):
+ def ll_destructor(addr, dummy):
assert dummy == llmemory.NULL
try:
v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG)
self.llinterp.eval_graph(destrgraph, [v], recursive=True)
except llinterp.LLException:
raise RuntimeError(
- "a finalizer raised an exception, shouldn't happen")
+ "a destructor raised an exception, shouldn't happen")
return llmemory.NULL
- return llhelper(gctypelayout.GCData.DESTRUCTOR_OR_CT, ll_finalizer)
+ return llhelper(gctypelayout.GCData.DESTRUCTOR_OR_CT, ll_destructor)
def make_custom_trace_funcptr_for_type(self, TYPE):
from rpython.memory.gctransform.support import get_rtti
@@ -242,8 +242,12 @@
def _call_finalizer(self, finalizer, obj):
FUNC = lltype.typeOf(finalizer.ptr).TO
obj = llmemory.cast_adr_to_ptr(obj, FUNC.ARGS[0])
- self.llinterp.eval_graph(finalizer.ptr._obj.graph, [obj],
- recursive=True)
+ try:
+ self.llinterp.eval_graph(finalizer.ptr._obj.graph, [obj],
+ recursive=True)
+ except llinterp.LLException:
+ raise RuntimeError(
+ "a finalizer raised an exception, shouldn't happen")
return True
diff --git a/rpython/memory/test/test_gc.py b/rpython/memory/test/test_gc.py
--- a/rpython/memory/test/test_gc.py
+++ b/rpython/memory/test/test_gc.py
@@ -12,6 +12,7 @@
from rpython.rlib import rgc
from rpython.rlib.rstring import StringBuilder
from rpython.rlib.rarithmetic import LONG_BIT
+from rpython.rlib.debug import debug_print
WORD = LONG_BIT // 8
@@ -224,7 +225,10 @@
self.id = b.nextid
b.nextid += 1
def finalizer(self):
- assert n.num_deleted <= b.num_finalized
+ if b.num_deleted > b.num_finalized:
+ debug_print("Oups! num_deleted =", b.num_deleted,
+ "but num_finalized =", b.num_finalized)
+ raise AssertionError
b.num_finalized += 1
def __del__(self):
b.num_deleted += 1
@@ -235,8 +239,13 @@
while i < x:
i += 1
a = A()
+ rgc.register_finalizer(a.finalizer)
+ a = None
+ debug_print("first collection (minor only)...")
+ llop.gc__collect(lltype.Void, 0)
+ debug_print("second collection...")
llop.gc__collect(lltype.Void)
- llop.gc__collect(lltype.Void)
+ debug_print("done")
return b.num_finalized * 100 + b.num_deleted
res = self.interpret(f, [5])
assert res == 606
More information about the pypy-commit
mailing list