[Python-bugs-list] [Bug #113850] posixfile __del__ method is wrong
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 8 Sep 2000 23:30:13 -0700
Bug #113850, was updated on 2000-Sep-07 21:43
Here is a current snapshot of the bug.
Project: Python
Category: Library
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 5
Summary: posixfile __del__ method is wrong
Details: The posixfile __del__ method attempts to close the
file (_file_) it contains. However, if the open
method fails, then _file_ is never assigned.
The solution is to modify __del__ as follows:
def __del__(self):
if hasattr(self, '_file_'):
self._file_.close()
-Kevin Jacobs (jacobs@darwin.cwru.edu)
Follow-Ups:
Date: 2000-Sep-08 13:04
By: loewis
Comment:
Why does posixfile need an __del__ in the first place? Deleting the instance
should release the underlying file object, which will close it. If anybody else
keeps the file object referenced, perhaps it even should stay open?
-------------------------------------------------------
Date: 2000-Sep-08 23:30
By: fdrake
Comment:
Removed the __del__() method in posixfile.py revision 1.16.
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=113850&group_id=5470