]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
d'oh! could have _sworn_ I checked this in last weekend.
authorAnthony Baxter <anthonybaxter@gmail.com>
Fri, 21 Dec 2001 04:46:19 +0000 (04:46 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Fri, 21 Dec 2001 04:46:19 +0000 (04:46 +0000)
Make dumbdbm merely "dumb", rather than "terminally broken". Without this
patch, it's almost impossible to use dumbdbm _without_ causing horrible
datalossage. With this patch, dumbdbm passes my own horrible torture test,
as well as the roundup test suite.

dumbdbm really could do with a smidgin of a rewrite or two, but that's not
suitable for the release21-maint branch.

This patch should go into the trunk as well.

Lib/dumbdbm.py

index f1cc41bd4503d2006aa6c66df733a5ec6d0d6d64..f71cb8ae677cc7579d50cdb36f7a5ee87a4ab448 100644 (file)
@@ -139,9 +139,14 @@ class _Database:
         return len(self._index)
 
     def close(self):
+        self._commit()
         self._index = None
         self._datfile = self._dirfile = self._bakfile = None
 
+    def __del__(self):
+        if self._index is not None:
+            self._commit()
+
 
 def open(file, flag = None, mode = None):
     # flag, mode arguments are currently ignored