]> granicus.if.org Git - python/commitdiff
Kevin Jacobs <jacobs@darwin.cwru.edu>:
authorFred Drake <fdrake@acm.org>
Sat, 9 Sep 2000 06:26:40 +0000 (06:26 +0000)
committerFred Drake <fdrake@acm.org>
Sat, 9 Sep 2000 06:26:40 +0000 (06:26 +0000)
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.

Lib/posixfile.py

index d358dc4ab7dc87494d171342db3f3b4a0715dcbb..18f72fd0e5836fcc338af07d6f8cda996b178f90 100644 (file)
@@ -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