python 2.7 documentation: file:///usr/share/doc/python-doc/html/library/stringio.html#StringIO.StringIO.close (or: http://docs.python.org/library/stringio.html#StringIO.StringIO.close ) says: """StringIO.close() Free the memory buffer. Attempting to do further operations with a closed StringIO object will raise a ValueError.""" But this code: def string_io_close_exception_test(): from StringIO import StringIO s=StringIO() s.write("asdf") s.close() try: # file:///usr/share/doc/python-doc/html/library/stringio.html#StringIO.StringIO.close doc = """ StringIO.close() Free the memory buffer. Attempting to do further operations with a closed StringIO object will raise a ValueError. """ s.getvalue() except ValueError: print "this is the expected" except Exception, e: print 'this is unexpected:',type(e), e raise produces this output: this is unexpected: <type 'exceptions.AttributeError'> StringIO instance has no attribute 'buf' Traceback (most recent call last): File "problems.py", line 192, in string_io() File "problems.py", line 184, in string_io s.getvalue() File "/usr/lib/python2.7/StringIO.py", line 270, in getvalue self.buf += ''.join(self.buflist) AttributeError: StringIO instance has no attribute 'buf'