]> granicus.if.org Git - python/commitdiff
Bug #1339007: Shelf objects now don't raise an exception in their
authorGeorg Brandl <georg@python.org>
Wed, 14 Jun 2006 06:08:31 +0000 (06:08 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 14 Jun 2006 06:08:31 +0000 (06:08 +0000)
__del__ method when initialization failed.

Lib/shelve.py
Misc/NEWS

index 4959c262c3ecec7a9f74439e7d02348c95a03e40..7a75445b0bf376c17361a2c319b76537a8daf241 100644 (file)
@@ -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):
index 3dbecd76c3f81d2b455525a0663bcd60b422f3aa..630d36b8457d6a18bc28085db8e5fd25da4a49a3 100644 (file)
--- 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.