summaryrefslogtreecommitdiffstats
path: root/Lib/dumbdbm.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-12-07 21:54:46 (GMT)
committerFred Drake <fdrake@acm.org>2001-12-07 21:54:46 (GMT)
commit2c8373bc234039fff699df9c28d2cb74efd6a37c (patch)
tree8017f519eb3ab042b905f6c62d477305be2a71e2 /Lib/dumbdbm.py
parent301d0f89bb81950230f401aae7df160ffa20b91a (diff)
downloadcpython-2c8373bc234039fff699df9c28d2cb74efd6a37c.zip
cpython-2c8373bc234039fff699df9c28d2cb74efd6a37c.tar.gz
cpython-2c8373bc234039fff699df9c28d2cb74efd6a37c.tar.bz2
Honor the mode argument to dumbdbm.open(); there is not good reason not to,
especially since the documentation described it in detail. This partially closes SF bug #490098.
Diffstat (limited to 'Lib/dumbdbm.py')
-rw-r--r--Lib/dumbdbm.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/dumbdbm.py b/Lib/dumbdbm.py
index d5df1d5..0fd2dad 100644
--- a/Lib/dumbdbm.py
+++ b/Lib/dumbdbm.py
@@ -32,7 +32,8 @@ error = IOError # For anydbm
class _Database:
- def __init__(self, file):
+ def __init__(self, file, mode):
+ self._mode = mode
self._dirfile = file + _os.extsep + 'dir'
self._datfile = file + _os.extsep + 'dat'
self._bakfile = file + _os.extsep + 'bak'
@@ -40,7 +41,7 @@ class _Database:
try:
f = _open(self._datfile, 'r')
except IOError:
- f = _open(self._datfile, 'w')
+ f = _open(self._datfile, 'w', self._mode)
f.close()
self._update()
@@ -63,7 +64,7 @@ class _Database:
except _os.error: pass
try: _os.rename(self._dirfile, self._bakfile)
except _os.error: pass
- f = _open(self._dirfile, 'w')
+ f = _open(self._dirfile, 'w', self._mode)
for key, (pos, siz) in self._index.items():
f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`))
f.close()
@@ -100,7 +101,7 @@ class _Database:
def _addkey(self, key, (pos, siz)):
self._index[key] = (pos, siz)
- f = _open(self._dirfile, 'a')
+ f = _open(self._dirfile, 'a', self._mode)
f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`))
f.close()
@@ -146,6 +147,6 @@ class _Database:
self._datfile = self._dirfile = self._bakfile = None
-def open(file, flag=None, mode=None):
+def open(file, flag=None, mode=0666):
# flag, mode arguments are currently ignored
- return _Database(file)
+ return _Database(file, mode)