Open GoogleCodeExporter opened 9 years ago
Original comment by gc...@loowis.durge.org
on 2 Sep 2012 at 5:12
I haven't actually tested this, but I think because you are running this inside
the interpreter that that your FileWrapperSub instance isn't actually going out
of scope there. The interpreter keeps the result of the last command in a
variable called '_', so there is still a reference to it after the last line.
If you put the code in a .py file and run it, I suspect it will work as you
would expect. If it doesn't, then it must be a bug.
Original comment by willmcgugan
on 3 Sep 2012 at 9:59
Just tested it, and you're absolutely right, and it does look like __del__
doesn't call close on itself, only on FileWrapperBase and the wrapped file. But
I think this may be intended behaviour. Best to run it by Ryan to be sure.
Original comment by willmcgugan
on 3 Sep 2012 at 10:32
IIRC, __del__ bypasses self.close() so that it can be sure that
self.wrapped_file is cleaned up properly, even if there happen to be errors in
the file wrapper itself.
Given that python will close self.wrapped_file when it's garbage collected
anyway, this may not be a valid concern. Just calling self.close() would
certainly simplify the code in FileWrapper.__del__.
Original comment by rfkel...@gmail.com
on 3 Sep 2012 at 10:03
Original issue reported on code.google.com by
gc...@loowis.durge.org
on 2 Sep 2012 at 5:11