[Python-bugs-list] [Bug #115530] cStringIO.StringIO() doesn't raise ValueError when closed

noreply@sourceforge.net noreply@sourceforge.net
Fri, 6 Oct 2000 12:27:50 -0700


Bug #115530, was updated on 2000-Sep-27 20:48
Here is a current snapshot of the bug.

Project: Python
Category: Modules
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 5
Summary: cStringIO.StringIO() doesn't raise ValueError when closed

Details: When write() is called on a closed StringO instance, ValueError should be raised.  Other methods should be checked for this as well.

>>> import cStringIO, StringIO
>>> f = cStringIO.StringIO()
>>> f.close()
>>> f.write('')

>>> f = StringIO.StringIO()    
>>> f.close()
>>> f.write('')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "./../Lib/StringIO.py", line 119, in write
    raise ValueError, "I/O operation on closed file"
ValueError: I/O operation on closed file

>>> f = open('junk.txt', 'w')
>>> f.close()
>>> f.write('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: I/O operation on closed file

Assigned to Ken since he works at Digital Creations and can pester Jim Fulton about this.

Follow-Ups:

Date: 2000-Sep-27 20:53
By: fdrake

Comment:
Oops -- fixed summary to refer to the proper exception.
-------------------------------------------------------

Date: 2000-Sep-27 21:27
By: fdrake

Comment:
A simple test for this is commented out in Lib/test/test_StringIO.py; please uncomment and regenerate output when fixing this bug.
-------------------------------------------------------

Date: 2000-Sep-30 07:29
By: loewis

Comment:
A patch is in http://sourceforge.net/patch/?func=detailpatch&patch_id=101721&group_id=5470

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=115530&group_id=5470