summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-12-09 14:18:33 +0000
committerGuido van Rossum <guido@python.org>1997-12-09 14:18:33 +0000
commit83a6f2c5846db9367b265411b2b70b28b95f927d (patch)
treeee0f07a937c107b4fbb3c5653d9dafd7c1bf6619 /Lib
parent45c68f0d1a1291b7a3754bc6c2bb69a554165a0f (diff)
downloadcpython-83a6f2c5846db9367b265411b2b70b28b95f927d.tar.gz
Make close(), and hence __del__(), robust in the light of the world
being destroyed already.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/shelve.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py
index b159e61380..9b65a0911f 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()