From: Georg Brandl Date: Wed, 14 Jun 2006 06:08:31 +0000 (+0000) Subject: Bug #1339007: Shelf objects now don't raise an exception in their X-Git-Tag: v2.5b1~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2605ca8773ebf37c840c191a903f168942521aa8;p=python Bug #1339007: Shelf objects now don't raise an exception in their __del__ method when initialization failed. --- diff --git a/Lib/shelve.py b/Lib/shelve.py index 4959c262c3..7a75445b0b 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -139,6 +139,9 @@ class Shelf(UserDict.DictMixin): self.dict = 0 def __del__(self): + if not hasattr(self, 'writeback'): + # __init__ didn't succeed, so don't bother closing + return self.close() def sync(self): diff --git a/Misc/NEWS b/Misc/NEWS index 3dbecd76c3..630d36b845 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -156,6 +156,9 @@ Extension Modules Library ------- +- Bug #1339007: Shelf objects now don't raise an exception in their + __del__ method when initialization failed. + - Patch #1455898: The MBCS codec now supports the incremental mode for double-byte encodings.