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 skip.montanaro
Recipients skip.montanaro
Date 2008-12-09.00:11:19
SpamBayes Score 7.990263e-08
Marked as misclassified No
Message-id <1228781481.66.0.10678075439.issue4604@psf.upfronthosting.co.za>
In-reply-to
Content
Seems like file.close() in 3.0 isn't much of a barrier to further reading:

% python3.0
Python 3.0rc3+ (py3k:67338M, Nov 22 2008, 06:47:23) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> fp = open("/etc/services")
>>> ct = fp.read(1048)
>>> print (ct[-80:], end='') ; fp.close() ; ct = fp.read(17) ; print (ct)
compressnet       2/udp     # Management Utility
compressnet       2/tcp     # Management Utility

The second read() should raise an exception.  Same code, 2.6:

% python2.6
Python 2.6+ (release26-maint:66821:66833, Oct 30 2008, 22:16:1) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> fp = open("/etc/services")
>>> ct = fp.read(1048)
>>> print (ct[-80:], end='') ; fp.close() ; ct = fp.read(17) ; print (ct)
compressnet       2/udp     # Management Utility
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
compressnet       2/tcp     # M>>> 

Culled this from a posting to comp.lang.python.
History
Date User Action Args
2008-12-09 00:11:21skip.montanarosetrecipients: + skip.montanaro
2008-12-09 00:11:21skip.montanarosetmessageid: <1228781481.66.0.10678075439.issue4604@psf.upfronthosting.co.za>
2008-12-09 00:11:20skip.montanarolinkissue4604 messages
2008-12-09 00:11:19skip.montanarocreate