New submission from alejandro david weil <[email protected]>:
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 <module>
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'
----------
components: Library (Lib)
messages: 136692
nosy: tenuki
priority: normal
severity: normal
status: open
title: StringIO AttributeError instead of ValueError after close..
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12161>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com