From: Georg Brandl Date: Wed, 14 Jun 2006 06:08:33 +0000 (+0000) Subject: Bug #1339007: Shelf objects now don't raise an exception in their X-Git-Tag: v2.4.4c1~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f66b00d5d50ffd7fb04ae8086c786e1b6609283;p=thirdparty%2FPython%2Fcpython.git Bug #1339007: Shelf objects now don't raise an exception in their __del__ method when initialization failed. (backport from rev. 46946) --- diff --git a/Lib/shelve.py b/Lib/shelve.py index 5e680bc3c68b..65e6cdbb6031 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -145,6 +145,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 005255fdaa7c..691d20981f87 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -53,6 +53,9 @@ Extension Modules Library ------- +- Bug #1339007: Shelf objects now don't raise an exception in their + __del__ method when initialization failed. + - Bug #1501223: Possible overflow in _PySys_Init() when reading the code page under Windows.