[pypy-commit] pypy default: test and fix for StringIO.readline(None)

bdkearns noreply at buildbot.pypy.org
Fri Apr 12 06:42:43 CEST 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r63258:63d556a4cffc
Date: 2013-04-12 00:37 -0400
http://bitbucket.org/pypy/pypy/changeset/63d556a4cffc/

Log:	test and fix for StringIO.readline(None)

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
@@ -169,9 +169,9 @@
         self.pos = end
         return space.wrap(u''.join(self.buf[start:end]))
 
-    @unwrap_spec(limit=int)
-    def readline_w(self, space, limit=-1):
+    def readline_w(self, space, w_limit=None):
         self._check_closed(space)
+        limit = convert_size(space, w_limit)
 
         if self.pos >= len(self.buf):
             return space.wrap(u"")
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
@@ -32,7 +32,7 @@
         raises(ValueError, sio.read, 1)
         raises(ValueError, sio.write, u"text")
 
-    def testRead(self):
+    def test_read(self):
         import io
         buf = u"1234567890"
         sio = io.StringIO(buf)
@@ -42,6 +42,13 @@
         assert buf[5:] == sio.read(900)
         assert u"" == sio.read()
 
+    def test_readline(self):
+        import io
+        sio = io.StringIO(u'123\n456')
+        assert sio.readline(2) == '12'
+        assert sio.readline(None) == '3\n'
+        assert sio.readline() == '456'
+
     def test_seek(self):
         import io
 


More information about the pypy-commit mailing list