From: Fred Drake Date: Sat, 9 Sep 2000 06:26:40 +0000 (+0000) Subject: Kevin Jacobs : X-Git-Tag: v2.0b2~392 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16c4aa441bba65ac0e4386e4b04d25119e8fc609;p=python Kevin Jacobs : The posixfile __del__ method attempts to close the file (_file_) it contains. However, if the open() method fails, then _file_ is never assigned. This closes SourceForge bug #113850. --- diff --git a/Lib/posixfile.py b/Lib/posixfile.py index d358dc4ab7..18f72fd0e5 100644 --- a/Lib/posixfile.py +++ b/Lib/posixfile.py @@ -68,7 +68,8 @@ class _posixfile_: hex(id(self))[2:]) def __del__(self): - self._file_.close() + if hasattr(self, "_file_"): + self._file_.close() # # Initialization routines