[pypy-svn] r79186 - in pypy/branch/fast-forward/pypy/module/_io: . test

afa at codespeak.net afa at codespeak.net
Wed Nov 17 13:01:23 CET 2010


Author: afa
Date: Wed Nov 17 13:01:22 2010
New Revision: 79186

Modified:
   pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
   pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py
   pypy/branch/fast-forward/pypy/module/_io/test/test_io.py
Log:
All io objects are weakrefable.


Modified: pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py	Wed Nov 17 13:01:22 2010
@@ -1,6 +1,5 @@
 from pypy.interpreter.typedef import (
-    TypeDef, interp_attrproperty, interp_attrproperty_w, GetSetProperty,
-    make_weakref_descr)
+    TypeDef, interp_attrproperty, interp_attrproperty_w, GetSetProperty)
 from pypy.interpreter.gateway import interp2app, unwrap_spec, Arguments
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError, wrap_oserror, wrap_oserror2
@@ -436,7 +435,6 @@
     __new__  = interp2app(W_FileIO.descr_new.im_func),
     __init__  = interp2app(W_FileIO.descr_init),
     __repr__ = interp2app(W_FileIO.repr_w),
-    __weakref__ = make_weakref_descr(W_FileIO),
 
     seek = interp2app(W_FileIO.seek_w),
     tell = interp2app(W_FileIO.tell_w),

Modified: pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py	Wed Nov 17 13:01:22 2010
@@ -1,6 +1,7 @@
 from pypy.interpreter.baseobjspace import ObjSpace, Wrappable, W_Root
 from pypy.interpreter.typedef import (
-    TypeDef, GetSetProperty, generic_new_descr, descr_get_dict, descr_set_dict)
+    TypeDef, GetSetProperty, generic_new_descr, descr_get_dict, descr_set_dict,
+    make_weakref_descr)
 from pypy.interpreter.gateway import interp2app, Arguments, unwrap_spec
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.rlib.rstring import StringBuilder
@@ -246,6 +247,7 @@
     _checkSeekable = interp2app(check_seekable_w),
     closed = GetSetProperty(W_IOBase.closed_get_w),
     __dict__ = GetSetProperty(descr_get_dict, descr_set_dict, cls=W_IOBase),
+    __weakref__ = make_weakref_descr(W_IOBase),
 
     readline = interp2app(W_IOBase.readline_w),
     readlines = interp2app(W_IOBase.readlines_w),

Modified: pypy/branch/fast-forward/pypy/module/_io/test/test_io.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/test/test_io.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/test/test_io.py	Wed Nov 17 13:01:22 2010
@@ -96,6 +96,13 @@
                 return 42
         assert MyIO().tell() == 42
 
+    def test_weakref(self):
+        import _io
+        import weakref
+        f = _io.BytesIO()
+        ref = weakref.ref(f)
+        assert ref() is f
+
 class AppTestOpen:
     def setup_class(cls):
         tmpfile = udir.join('tmpfile').ensure()



More information about the Pypy-commit mailing list