diff --git a/Lib/shelve.py b/Lib/shelve.py index fb2fa93b010..8271dfeddca 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -136,7 +136,11 @@ def close(self): self.dict.close() except AttributeError: pass - self.dict = _ClosedDict() + # _ClosedDict can be None when close is called from __del__ during shutdown + if _ClosedDict is None: + self.dict = None + else: + self.dict = _ClosedDict() def __del__(self): if not hasattr(self, 'writeback'): diff --git a/Misc/NEWS b/Misc/NEWS index cb489dd4f26..762def27c58 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -242,6 +242,9 @@ C-API Library ------- +- Issue #7835: shelve should no longer produce mysterious warnings during + interpreter shutdown. + - Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">") in XML processing instructions and comments. These raw characters are allowed by the XML specification, and are necessary when outputting e.g.