+1 on getting rid of the IOBase __del__ in the C rewrite in favor of tp_dealloc.<br><br><div class="gmail_quote">On Sun, Jan 18, 2009 at 11:53 PM, Christian Heimes <span dir="ltr">&lt;<a href="mailto:lists@cheimes.de">lists@cheimes.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Brett Cannon schrieb:<br>
<div class="Ih2E3d">&gt; Fine by me. People should be using the context manager for guaranteed<br>
&gt; file closure anyway IMO.</div></blockquote><div><br></div><div>Yes they should. &nbsp;(how I really really wish i didn&#39;t have to use 2.4 anymore ;)</div><div><br></div><div>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.</div>
<div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="Ih2E3d">
<br>
</div>You make a very good point! Perhaps we should stop promising that files<br>
get closed as soon as possible and encourage people in using the with<br>
statement.<br>
<font color="#888888"><br>
Christian<br>
</font><div><div></div><div class="Wj3C7c"></div></div></blockquote><div><br></div><div>eegads, do we actually -promise- that somewhere? &nbsp;If so I&#39;ll happily go update those docs with a caveat.</div><div><br></div><div>
I regularly point out in code reviews that the very convenient and common idiom of open(name, &#39;w&#39;).write(data) doesn&#39;t guarantee when the file will be closed; its up to the GC implementation details. &nbsp;Good code should never depend on the GC for a timely release of scarce external resources (file descriptors/handles).</div>
<div><br></div></div>