summaryrefslogtreecommitdiffstats
path: root/Lib/shelve.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-02-11 01:56:42 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-02-11 01:56:42 (GMT)
commit031ae6e9049dc7db2208ed5a368d123c05975a8d (patch)
treec5672427b3af0e9fae1ffc359a6207fded9d45ad /Lib/shelve.py
parent7c29f071d52f9b666974d40cc061b4ea03439d1e (diff)
downloadcpython-031ae6e9049dc7db2208ed5a368d123c05975a8d.zip
cpython-031ae6e9049dc7db2208ed5a368d123c05975a8d.tar.gz
cpython-031ae6e9049dc7db2208ed5a368d123c05975a8d.tar.bz2
Improve issue 7835 fix per MAL to handle the case that the
module dictionary has also been cleared.
Diffstat (limited to 'Lib/shelve.py')
-rw-r--r--Lib/shelve.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py
index 8055f42..c8cba85 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -145,11 +145,12 @@ class Shelf(UserDict.DictMixin):
self.dict.close()
except AttributeError:
pass
- # _ClosedDict can be None when close is called from __del__ during shutdown
- if _ClosedDict is None:
- self.dict = None
- else:
+ # Catch errors that may happen when close is called from __del__
+ # because CPython is in interpreter shutdown.
+ try:
self.dict = _ClosedDict()
+ except (NameError, TypeError):
+ self.dict = None
def __del__(self):
if not hasattr(self, 'writeback'):