New submission from Skip Montanaro <[EMAIL PROTECTED]>:

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.

----------
components: Interpreter Core
messages: 77376
nosy: skip.montanaro
severity: normal
status: open
title: close() seems to have limited effect
type: behavior
versions: Python 3.0

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4604>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to