Antoine Pitrou <pit...@free.fr> added the comment:

> It allows garbage collection to close the file object if there are no 
> more references to it.

This is a very bad policy to begin with. Garbage collection can be delayed for 
a number of reasons:
- someone might be running your program on a Python implementation which 
doesn't use reference counting (such as Jython or PyPy)
- an exception, together with its traceback object, might capture the value of 
some local variables and keep them alive (that is, reachable from the GC's 
point of view)
- a reference cycle might delay proper resource cleanup until the cyclic 
garbage collector kicks in

So the good thing to do is to close your file explicitly. Luckily, Python 2.6 
and upwards makes it easier by using the "with" statement.

IMO this issue should be closed.

----------
resolution:  -> rejected
stage: unit test needed -> 
status: open -> pending
versions:  -Python 2.5, Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10855>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to