summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/shelve.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py
index b159e61..9b65a09 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()