[pypy-commit] pypy refactor-wrapped-del: Use the nice interface here.

arigo noreply at buildbot.pypy.org
Mon Jul 11 19:17:04 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: refactor-wrapped-del
Changeset: r45470:717909759edc
Date: 2011-07-11 14:02 +0200
http://bitbucket.org/pypy/pypy/changeset/717909759edc/

Log:	Use the nice interface here.

diff --git a/pypy/module/_io/interp_bufferedio.py b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -838,9 +838,9 @@
             self.w_writer = None
             raise
 
-    def __del__(self):
-        self.clear_all_weakrefs()
-        # Don't call the base __del__: do not close the files!
+    def destructor(self):
+        # method overriden to not close the files
+        pass
 
     # forward to reader
     for method in ['read', 'peek', 'read1', 'readinto', 'readable']:
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
@@ -1,7 +1,7 @@
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import (
     TypeDef, GetSetProperty, generic_new_descr, descr_get_dict, descr_set_dict,
-    make_weakref_descr)
+    make_weakref_descr, builtin_destructor)
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.rlib.rstring import StringBuilder
@@ -55,8 +55,7 @@
             return True
         return False
 
-    def __del__(self):
-        self.clear_all_weakrefs()
+    def destructor(self):
         space = self.space
         w_closed = space.findattr(self, space.wrap('closed'))
         try:
@@ -69,6 +68,7 @@
             # equally as bad, and potentially more frequent (because of
             # shutdown issues).
             pass
+    builtin_destructor(locals(), 'destructor', Wrappable)
 
     def _CLOSED(self):
         # Use this macro whenever you want to check the internal `closed`


More information about the pypy-commit mailing list