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

Alexandre Vassalotti alexandre at peadrop.com
Thu Jun 28 16:37:01 CEST 2007


Can someone, other than Guido, review my patch? He is in vacation
right now, so he probably won't have the time to review and submit it
until August.

Thanks,
-- Alexandre

On 6/25/07, Alexandre Vassalotti <alexandre at peadrop.com> wrote:
> On 6/23/07, Guido van Rossum <guido at python.org> wrote:
> > On 6/23/07, Alexandre Vassalotti <alexandre at peadrop.com> wrote:
> > > I agree with this. I will try to write a patch to fix io.BytesIO.
> >
> > Great!
>
> I got the patch (it's attached to this email). The fix was simpler
> than I thought.
>
> I would like to write a unittest for it, but I am not sure where it
> should go in test_io.py. From what I see, MemorySeekTestMixin is for
> testing read/seek operation common to BytesIO and StringIO, so I can't
> put it there. And I don't really like the idea of adding another test
> in IOTest.test_raw_bytes_io.
>
> By the way, I am having the same problem for the tests of _string_io
> and _bytes_io -- i.e., I don't know exactly how to organize them with
> the rest of the tests in test_io.py.
>
> > > Free the resources held by the object, and make all methods of the
> > > object raise a ValueError if they are used.
> >
> > I'm not sure what the use case for that is (even though the 2.x
> > StringIO does this).
> >
>
> It seem the close method on TextIOWrapper objects is broken too (or at
> least, bizarre):
>
>     >>> f = open('test', 'w')
>     >>> f.write('hello')
>     5
>     >>> f.close()
>     >>> f.write('hello')
>     5
>     >>> ^D
>     $ hd test
>     00000000  68 65 6c 6c 6f                                    |hello|
>     00000005
>
>
> -- Alexandre
>
>


-- 
Alexandre Vassalotti


More information about the Python-3000 mailing list