[Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly

Alexandre Vassalotti alexandre at peadrop.com
Sat Jun 23 17:53:35 CEST 2007


Hello,

I think found a bug in the implementation of StringIO/BytesIO in the
new io module.  I would like to fix it, but I am not sure what should
be the correct behavior. Any hint on this?

And one more thing, the close method on StringIO/BytesIO objects
doesn't work.  I will try to fix that too.

Thanks,
-- Alexandre

Python 3.0x (py3k-struni:56080M, Jun 22 2007, 17:18:04)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> s1 = io.StringIO()
>>> s1.seek(10)
10
>>> s1.write('hello')
5
>>> s1.getvalue()
'hello'
>>> s1.seek(0)
0
>>> s1.write('abc')
3
>>> s1.getvalue()
'abclo'
>>> import StringIO
>>> s2 = StringIO.StringIO()
>>> s2.seek(10)
>>> s2.write('hello')
>>> s2.getvalue()
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00hello'
>>> s2.seek(0)
>>> s2.write('abc')
>>> s2.getvalue()
'abc\x00\x00\x00\x00\x00\x00\x00hello'


More information about the Python-3000 mailing list