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

2007-07-20 Thread Guido van Rossum
They shouldn't, really, and I don't care too much about what happens in that case. It may depend on whether the I/O device honors seeks beyond EOF or not. On 7/20/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > How this different from setting the position to the new size? What > should happe

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

2007-07-20 Thread Alexandre Vassalotti
How this different from setting the position to the new size? What should happen when someone call truncate() with an argument greater than the current size? Should it do a seek, or nothing? Thanks, -- Alexandre On 7/18/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Unless anyone cares, it sho

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

2007-07-18 Thread Guido van Rossum
Unless anyone cares, it should imply a seek to the indicated position if an argument was present. On 7/18/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > So, any decision on the proposed semantic change of truncate? > > -- Alexandre > > On 7/3/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wro

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

2007-07-18 Thread Alexandre Vassalotti
So, any decision on the proposed semantic change of truncate? -- Alexandre On 7/3/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > On 7/2/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Honestly, I think truncate() should always set the current position to > > the new size, even though t

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

2007-07-03 Thread Paul Moore
On 03/07/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > I also find the semantic make more sense too. For example: > > >>> s = StringIO("Good bye, world") > >>> s.truncate(10) > >>> s.write("cruel world") > >>> s.getvalue() > ??? > > I think that should return "Good bye, cruel worl

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

2007-07-03 Thread Alexandre Vassalotti
On 7/2/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Honestly, I think truncate() should always set the current position to > the new size, even though that's not what it currently does. Thought about that and I think that would be the best thing to do. That would avoid making StringIO unneces

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

2007-07-02 Thread Guido van Rossum
Honestly, I think truncate() should always set the current position to the new size, even though that's not what it currently does. Or at least it should set it to the new size if that's less than the current position. What's the rationale (apart from "Unix defined it so") why it currently leaves t

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

2007-07-02 Thread Alexandre Vassalotti
On 7/2/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Honestly, I think truncate() should always set the current position to > the new size, even though that's not what it currently does. Or at > least it should set it to the new size if that's less than the current > position. What's the ration

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

2007-07-02 Thread Alexandre Vassalotti
If StringIO is not allowed to over-seek, what should happen to the current file position when it is truncated? >>> s = StringIO("Hello world!") >>> s.seek(0, 2) >>> s.truncate(2) >>> s.tell() ??? Truncating can either set the position to the new string size, or it leaves it alone.

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

2007-06-28 Thread Alexandre Vassalotti
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 <[EMAIL PROTECTED]> wrote: > On 6/23/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 6

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

2007-06-25 Thread Alexandre Vassalotti
On 6/23/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: On 6/23/07, Alexandre Vassalotti <[EMAIL PROTECTED]> 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 wri

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

2007-06-23 Thread Guido van Rossum
On 6/23/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > On 6/23/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 6/23/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > > > I think found a bug in the implementation of StringIO/BytesIO in the > > > new io module. I would like to fix

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

2007-06-23 Thread Alexandre Vassalotti
On 6/23/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 6/23/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > > 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 h

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

2007-06-23 Thread Guido van Rossum
On 6/23/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > 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? BytesIO should behave the way Unix file

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

2007-06-23 Thread Alexandre Vassalotti
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.