[pypy-svn] pypy fast-forward: io.StringIO is readable, writable, seekable

amauryfa commits-noreply at bitbucket.org
Fri Jan 7 17:56:06 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40462:740f003e9637
Date: 2011-01-07 14:55 +0100
http://bitbucket.org/pypy/pypy/changeset/740f003e9637/

Log:	io.StringIO is readable, writable, seekable

diff --git a/pypy/module/_io/test/test_stringio.py b/pypy/module/_io/test/test_stringio.py
--- a/pypy/module/_io/test/test_stringio.py
+++ b/pypy/module/_io/test/test_stringio.py
@@ -8,6 +8,14 @@
 
         assert io.StringIO(u"hello").read() == u'hello'
 
+    def test_capabilities(self):
+        import io
+        sio = io.StringIO()
+        assert sio.readable()
+        assert sio.writable()
+        assert sio.seekable()
+        sio.close()
+
     def test_closed(self):
         import io
         sio = io.StringIO()

diff --git a/pypy/module/_io/interp_stringio.py b/pypy/module/_io/interp_stringio.py
--- a/pypy/module/_io/interp_stringio.py
+++ b/pypy/module/_io/interp_stringio.py
@@ -78,6 +78,18 @@
         return space.wrap(u''.join(self.buf))
 
     @unwrap_spec('self', ObjSpace)
+    def readable_w(self, space):
+        return space.w_True
+
+    @unwrap_spec('self', ObjSpace)
+    def writable_w(self, space):
+        return space.w_True
+
+    @unwrap_spec('self', ObjSpace)
+    def seekable_w(self, space):
+        return space.w_True
+
+    @unwrap_spec('self', ObjSpace)
     def close_w(self, space):
         self.buf = None
 
@@ -91,6 +103,9 @@
     write=interp2app(W_StringIO.write_w),
     read=interp2app(W_StringIO.read_w),
     getvalue=interp2app(W_StringIO.getvalue_w),
+    readable = interp2app(W_StringIO.readable_w),
+    writable = interp2app(W_StringIO.writable_w),
+    seekable = interp2app(W_StringIO.seekable_w),
     close = interp2app(W_StringIO.close_w),
     closed = GetSetProperty(W_StringIO.closed_get_w),
     )


More information about the Pypy-commit mailing list