ignore errors when trying to delete temporary files.

This commit is contained in:
Kovid Goyal 2007-12-15 22:06:40 +00:00
parent a8cfef8a60
commit f37d8c9dc4

View File

@ -42,10 +42,13 @@ class _TemporaryFileWrapper(object):
return a return a
def __del__(self): def __del__(self):
import os # Needs to be here as the main os may no longer exist try:
self.close() import os # Needs to be here as the main os may no longer exist
if self.name and os.access(self.name, os.F_OK): self.close()
os.remove(self.name) if self.name and os.access(self.name, os.F_OK):
os.remove(self.name)
except: # An error just means that deleting of temporary file failed
pass
def PersistentTemporaryFile(suffix="", prefix="", dir=None): def PersistentTemporaryFile(suffix="", prefix="", dir=None):