]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1339007: Shelf objects now don't raise an exception in their
authorGeorg Brandl <georg@python.org>
Wed, 14 Jun 2006 06:08:33 +0000 (06:08 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 14 Jun 2006 06:08:33 +0000 (06:08 +0000)
__del__ method when initialization failed.
 (backport from rev. 46946)

Lib/shelve.py
Misc/NEWS

index 5e680bc3c68b6a0d624a91c8f1559773bf289c43..65e6cdbb6031b6b2ff73b5fff492d468cdbb4665 100644 (file)
@@ -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):
index 005255fdaa7c81bb1da8ee79ceff146c53d33f51..691d20981f87f59f530b98fbc9d019bec9565425 100644 (file)
--- 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.