Make close(), and hence __del__(), robust in the light of the world

being destroyed already.
This commit is contained in:
Guido van Rossum 1997-12-09 14:18:33 +00:00
parent 19b55f2d17
commit 6599fb0917
1 changed files with 6 additions and 3 deletions

View File

@ -74,9 +74,12 @@ class Shelf:
del self.dict[key]
def close(self):
if hasattr(self.dict, 'close'):
try:
if self.dict:
self.dict.close()
self.dict = None
except:
pass
self.dict = 0
def __del__(self):
self.close()