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 pitrou
Recipients georg.brandl, ned.deily, pitrou, pjcreath
Date 2011-01-12.21:05:01
SpamBayes Score 2.384449e-09
Marked as misclassified No
Message-id <1294866305.99.0.882142664623.issue10855@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2011-01-12 21:05:06pitrousetrecipients: + pitrou, georg.brandl, ned.deily, pjcreath
2011-01-12 21:05:05pitrousetmessageid: <1294866305.99.0.882142664623.issue10855@psf.upfronthosting.co.za>
2011-01-12 21:05:01pitroulinkissue10855 messages
2011-01-12 21:05:01pitroucreate