]> granicus.if.org Git - python/commitdiff
Make close(), and hence __del__(), robust in the light of the world
authorGuido van Rossum <guido@python.org>
Tue, 9 Dec 1997 14:18:33 +0000 (14:18 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 9 Dec 1997 14:18:33 +0000 (14:18 +0000)
being destroyed already.

Lib/shelve.py

index b159e61380794a82db2cdd60d6c8c26f577f278f..9b65a0911fa6bd376aca9a613af62008a78b9e5a 100644 (file)
@@ -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()