[pypy-svn] pypy default: Fix test_overseek.
alex_gaynor
commits-noreply at bitbucket.org
Sun Jan 30 06:48:41 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r41471:77ff14cd6f37
Date: 2011-01-30 00:24 -0500
http://bitbucket.org/pypy/pypy/changeset/77ff14cd6f37/
Log: Fix test_overseek.
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
@@ -58,6 +58,23 @@
sio.close()
raises(ValueError, sio.seek, 0)
+ def test_overseek(self):
+ import io
+
+ s = u"1234567890"
+ sio = io.StringIO(s)
+
+ res = sio.seek(11)
+ assert res == 11
+ res = sio.read()
+ assert res == u""
+ assert sio.tell() == 11
+ assert sio.getvalue() == s
+ sio.write(u"")
+ assert sio.getvalue() == s
+ sio.write(s)
+ assert sio.getvalue() == s + u"\0" + s
+
def test_tell(self):
import io
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
@@ -67,6 +67,8 @@
size = convert_size(space, w_size)
start = self.pos
available = len(self.buf) - start
+ if available <= 0:
+ return space.wrap(u"")
if size >= 0 and size <= available:
end = start + size
else:
More information about the Pypy-commit
mailing list