[pypy-svn] pypy default: Fix StringIO.isatty() when its closed, and some Buffered reprs.

alex_gaynor commits-noreply at bitbucket.org
Sun Jan 30 08:22:36 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r41472:d745077dc6dd
Date: 2011-01-30 01:49 -0500
http://bitbucket.org/pypy/pypy/changeset/d745077dc6dd/

Log:	Fix StringIO.isatty() when its closed, and some Buffered reprs.

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
@@ -188,15 +188,16 @@
     @unwrap_spec('self', ObjSpace)
     def repr_w(self, space):
         typename = space.type(self).getname(space, '?')
+        module = space.str_w(space.type(self).get_module())
         try:
             w_name = space.getattr(self, space.wrap("name"))
         except OperationError, e:
             if not e.match(space, space.w_AttributeError):
                 raise
-            return space.wrap("<%s>" % (typename,))
+            return space.wrap("<%s.%s>" % (module, typename,))
         else:
-            w_repr = space.repr(w_name)
-            return space.wrap("<%s name=%s>" % (typename, space.str_w(w_repr)))
+            name_repr = space.str_w(space.repr(w_name))
+            return space.wrap("<%s.%s name=%s>" % (module, typename, name_repr))
 
     # ______________________________________________
 

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
@@ -132,6 +132,7 @@
 
     @unwrap_spec('self', ObjSpace)
     def isatty_w(self, space):
+        self._check_closed(space)
         return space.w_False
 
     @unwrap_spec('self', ObjSpace)

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
@@ -14,7 +14,14 @@
         assert sio.readable()
         assert sio.writable()
         assert sio.seekable()
+        assert not sio.isatty()
+        assert not sio.closed
         sio.close()
+        assert sio.readable()
+        assert sio.writable()
+        assert sio.seekable()
+        raises(ValueError, sio.isatty)
+        assert sio.closed
 
     def test_closed(self):
         import io


More information about the Pypy-commit mailing list