summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Baxter <anthonybaxter@gmail.com>2001-12-21 05:13:37 (GMT)
committerAnthony Baxter <anthonybaxter@gmail.com>2001-12-21 05:13:37 (GMT)
commited9057083bcdcce37ddb66bc01e9b7fddb5ea206 (patch)
tree4efd7b1937dc39a3be76e8b3d32c695717c4a9dd
parentbec5b362db9848e291219539a466b9e2c5fcbe25 (diff)
downloadcpython-ed9057083bcdcce37ddb66bc01e9b7fddb5ea206.zip
cpython-ed9057083bcdcce37ddb66bc01e9b7fddb5ea206.tar.gz
cpython-ed9057083bcdcce37ddb66bc01e9b7fddb5ea206.tar.bz2
forward-patch from release21-maint branch:
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.
-rw-r--r--Lib/dumbdbm.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/dumbdbm.py b/Lib/dumbdbm.py
index 0fd2dad..920a464 100644
--- a/Lib/dumbdbm.py
+++ b/Lib/dumbdbm.py
@@ -143,9 +143,15 @@ 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=0666):
# flag, mode arguments are currently ignored