[Python-Dev] Iterating a closed StringIO

Walter Dörwald walter at livinglogic.de
Fri Nov 18 01:03:26 CET 2005


Am 17.11.2005 um 22:03 schrieb Guido van Rossum:

> On 11/17/05, Walter Dörwald <walter at livinglogic.de> wrote:
>> Currently StringIO.StringIO and cStringIO.StringIO behave differently
>> when iterating a closed stream:
>>
>> s = StringIO.StringIO("foo")
>> s.close()
>> s.next()
>>
>> gives StopIteration, but
>>
>> s = cStringIO.StringIO("foo")
>> s.close()
>> s.next()
>>
>> gives "ValueError: I/O operation on closed file".
>>
>> Should they raise the same exception? Should this be fixed for 2.5?
>
> I think cStringIO is doing the right thing; "real" files behave the  
> same way.
>
> Submit a patch for StringIO (also docs please) and assign it to me and
> I'll make sure it goes in.

http://www.python.org/sf/1359365

Doc/lib/libstringio.tex only states "See the description of file  
objects for operations", so I'm not sure how to update the  
documentation.

Bye,
    Walter Dörwald



More information about the Python-Dev mailing list