[pypy-commit] pypy gc-del: Fix _io to call close() between bytecodes too. A hack for tests.
arigo
noreply at buildbot.pypy.org
Fri Apr 26 18:14:34 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: gc-del
Changeset: r63655:7acc15347cae
Date: 2013-04-26 18:14 +0200
http://bitbucket.org/pypy/pypy/changeset/7acc15347cae/
Log: Fix _io to call close() between bytecodes too. A hack for tests.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -165,6 +165,13 @@
def _invoke_finalizer(self):
# The call-back from rgc.register_finalizer(), cannot be overridden
+ if not we_are_translated():
+ # haaaaaack in case this object is from an older test, to
+ # prevent it from blocking the future calls of finalizers...
+ from rpython.rlib import rgc
+ for x, y in rgc._finalizer_queue:
+ if getattr(x, 'space', None) not in (self, None):
+ return # there is a pending object with another space
self.invoke_finalizer()
def invoke_finalizer(self):
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -63,6 +63,10 @@
def invoke_finalizer(self):
self.clear_all_weakrefs()
+ self.finalizer_perform(self.space, 'close() method of ',
+ self._finalizer_close)
+
+ def _finalizer_close(self):
space = self.space
w_closed = space.findattr(self, space.wrap('closed'))
try:
More information about the pypy-commit
mailing list