(original) (raw)
+1 on getting rid of the IOBase __del__ in the C rewrite in favor of tp_dealloc.
On Sun, Jan 18, 2009 at 11:53 PM, Christian Heimes <lists@cheimes.de> wrote:
Brett Cannon schrieb:
> Fine by me. People should be using the context manager for guaranteed
> file closure anyway IMO.
Yes they should. (how I really really wish i didn't have to use 2.4 anymore ;)
But lets at least be clear that is never acceptable for a python implementation to leak file descriptors/handles (or other system resources), they should be closed and released whenever the particular GC implementation gets around to it.
You make a very good point! Perhaps we should stop promising that files
get closed as soon as possible and encourage people in using the with
statement.
Christian
eegads, do we actually -promise- that somewhere? If so I'll happily go update those docs with a caveat.
I regularly point out in code reviews that the very convenient and common idiom of open(name, 'w').write(data) doesn't guarantee when the file will be closed; its up to the GC implementation details. Good code should never depend on the GC for a timely release of scarce external resources (file descriptors/handles).