summaryrefslogtreecommitdiffstats
path: root/Lib/shelve.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-12-09 14:18:33 (GMT)
committerGuido van Rossum <guido@python.org>1997-12-09 14:18:33 (GMT)
commit6599fb0917704247f72b3338e622ebcbb94ba207 (patch)
tree4b547af712c7903c666a17f19e112342bdc93572 /Lib/shelve.py
parent19b55f2d17d2a189f9b48844c06d501f25ca6dc5 (diff)
downloadcpython-6599fb0917704247f72b3338e622ebcbb94ba207.zip
cpython-6599fb0917704247f72b3338e622ebcbb94ba207.tar.gz
cpython-6599fb0917704247f72b3338e622ebcbb94ba207.tar.bz2
Make close(), and hence __del__(), robust in the light of the world
being destroyed already.
Diffstat (limited to 'Lib/shelve.py')
-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()