Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6599fb0

Browse files
committed
Make close(), and hence __del__(), robust in the light of the world
being destroyed already.
1 parent 19b55f2 commit 6599fb0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/shelve.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ def __delitem__(self, key):
7474
del self.dict[key]
7575

7676
def close(self):
77-
if hasattr(self.dict, 'close'):
78-
self.dict.close()
79-
self.dict = None
77+
try:
78+
if self.dict:
79+
self.dict.close()
80+
except:
81+
pass
82+
self.dict = 0
8083

8184
def __del__(self):
8285
self.close()

0 commit comments

Comments
 (0)