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

afa at codespeak.net afa at codespeak.net
Wed Oct 20 13:21:11 CEST 2010


Author: afa
Date: Wed Oct 20 13:21:09 2010
New Revision: 78121

Modified:
   pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
   pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py
Log:
Add FileIO.closefd attribute


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 Oct 20 13:21:09 2010
@@ -1,6 +1,6 @@
 from pypy.module._io.interp_iobase import W_RawIOBase
 from pypy.interpreter.typedef import (
-    TypeDef, interp_attrproperty_w, GetSetProperty)
+    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
@@ -366,6 +366,7 @@
     fileno = interp2app(W_FileIO.fileno_w),
     isatty = interp2app(W_FileIO.isatty_w),
     name = interp_attrproperty_w('w_name', cls=W_FileIO),
+    closefd = interp_attrproperty('closefd', cls=W_FileIO),
     mode = GetSetProperty(W_FileIO.descr_get_mode),
     )
 

Modified: pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py	Wed Oct 20 13:21:09 2010
@@ -18,15 +18,18 @@
         f = _io.FileIO(self.tmpfile, 'a')
         assert f.name.endswith('tmpfile')
         assert f.mode == 'wb'
+        assert f.closefd is True
         f.close()
 
     def test_open_fd(self):
         import _io
         os = self.posix
         fd = os.open(self.tmpfile, os.O_RDONLY, 0666)
-        f = _io.FileIO(fd, "rb")
+        f = _io.FileIO(fd, "rb", closefd=False)
         assert f.fileno() == fd
+        assert f.closefd is False
         f.close()
+        os.close(fd)
 
     def test_open_directory(self):
         import _io



More information about the Pypy-commit mailing list