homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author blep
Recipients blep, georg.brandl
Date 2009年12月26日.20:48:33
SpamBayes Score 1.1453674e-09
Marked as misclassified No
Message-id <1261860516.82.0.572008344206.issue7578@psf.upfronthosting.co.za>
In-reply-to
Content
The io.IOBase class doc says:
"""Note that calling any method (even inquiries) on a closed stream is
undefined. Implementations may raise IOError in this case."""
But the io.IOBase.close() method document says:
"""Once the file is closed, any operation on the file (e.g. reading or
writing) will raise an IOError."""
which unlike the class doc is not conditional about the behavior...
Experimentation (see below) show that I get a ValueError in practice
(python 3.1, but also true for 2.6) with io.BufferedWriter and
io.StringIO objects.
>>> with open( 'dummy', 'wb') as f:
... pass
...
>>> f.write( b'' )
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: write to closed file
>>> f.writable()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> import io
>>> s = io.StringIO()
>>> s.close()
>>> s.read()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
History
Date User Action Args
2009年12月26日 20:48:36blepsetrecipients: + blep, georg.brandl
2009年12月26日 20:48:36blepsetmessageid: <1261860516.82.0.572008344206.issue7578@psf.upfronthosting.co.za>
2009年12月26日 20:48:34bleplinkissue7578 messages
2009年12月26日 20:48:34blepcreate

AltStyle によって変換されたページ (->オリジナル) /