From: Guido van Rossum Date: Tue, 9 Dec 1997 14:18:33 +0000 (+0000) Subject: Make close(), and hence __del__(), robust in the light of the world X-Git-Tag: v1.5b2~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6599fb0917704247f72b3338e622ebcbb94ba207;p=thirdparty%2FPython%2Fcpython.git Make close(), and hence __del__(), robust in the light of the world being destroyed already. --- diff --git a/Lib/shelve.py b/Lib/shelve.py index b159e6138079..9b65a0911fa6 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -74,9 +74,12 @@ class Shelf: del self.dict[key] def close(self): - if hasattr(self.dict, 'close'): - self.dict.close() - self.dict = None + try: + if self.dict: + self.dict.close() + except: + pass + self.dict = 0 def __del__(self): self.close()