Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r62612:9cb237badb3b
Date: 2013-03-21 07:03 -0400
http://bitbucket.org/pypy/pypy/changeset/9cb237badb3b/

Log:    small tweaks for RStringIO

diff --git a/rpython/rlib/rStringIO.py b/rpython/rlib/rStringIO.py
--- a/rpython/rlib/rStringIO.py
+++ b/rpython/rlib/rStringIO.py
@@ -120,7 +120,7 @@
         if p == 0 and n < 0:
             self.pos = AT_END
             return self.getvalue()     # reading everything
-        if p == AT_END:
+        if p == AT_END or n == 0:
             return ''
         assert p >= 0
         self.copy_into_bigbuffer()
@@ -138,12 +138,14 @@
             return ''.join(self.bigbuffer[p:p+count])
 
     def readline(self, size=-1):
-        p = self.tell()
+        p = self.pos
+        if p == AT_END or size == 0:
+            return ''
+        assert p >= 0
         self.copy_into_bigbuffer()
         end = len(self.bigbuffer)
         if size >= 0 and size < end - p:
             end = p + size
-        assert p >= 0
         i = p
         while i < end:
             finished = self.bigbuffer[i] == '\n'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to