[Python-checkins] r45319 - in python/trunk/Lib: bsddb/__init__.py test/test_bsddb.py
gregory.p.smith
python-checkins at python.org
Wed Apr 12 22:35:02 CEST 2006
Author: gregory.p.smith
Date: Wed Apr 12 22:35:02 2006
New Revision: 45319
Modified:
python/trunk/Lib/bsddb/__init__.py
python/trunk/Lib/test/test_bsddb.py
Log:
Fixes bug #1117761
bsddb.*open() methods cachesize parameter wouldn't work (raised an
internal bsddb.db exception when it was given). The set_cachesize
call needed to be moved from the DB object to the DBEnv since the env
was introduced to allow for threading.
(will backport to 2.4)
Modified: python/trunk/Lib/bsddb/__init__.py
==============================================================================
--- python/trunk/Lib/bsddb/__init__.py (original)
+++ python/trunk/Lib/bsddb/__init__.py Wed Apr 12 22:35:02 2006
@@ -287,10 +287,9 @@
cachesize=None, lorder=None, hflags=0):
flags = _checkflag(flag, file)
- e = _openDBEnv()
+ e = _openDBEnv(cachesize)
d = db.DB(e)
d.set_flags(hflags)
- if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder)
if ffactor is not None: d.set_h_ffactor(ffactor)
@@ -305,9 +304,8 @@
pgsize=None, lorder=None):
flags = _checkflag(flag, file)
- e = _openDBEnv()
+ e = _openDBEnv(cachesize)
d = db.DB(e)
- if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder)
d.set_flags(btflags)
@@ -324,9 +322,8 @@
rlen=None, delim=None, source=None, pad=None):
flags = _checkflag(flag, file)
- e = _openDBEnv()
+ e = _openDBEnv(cachesize)
d = db.DB(e)
- if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder)
d.set_flags(rnflags)
@@ -339,8 +336,13 @@
#----------------------------------------------------------------------
-def _openDBEnv():
+def _openDBEnv(cachesize):
e = db.DBEnv()
+ if cachesize is not None:
+ if cachesize >= 20480:
+ e.set_cachesize(0, cachesize)
+ else:
+ raise error, "cachesize must be >= 20480"
e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL)
return e
Modified: python/trunk/Lib/test/test_bsddb.py
==============================================================================
--- python/trunk/Lib/test/test_bsddb.py (original)
+++ python/trunk/Lib/test/test_bsddb.py Wed Apr 12 22:35:02 2006
@@ -14,7 +14,7 @@
openflag = 'c'
def setUp(self):
- self.f = self.openmethod[0](self.fname, self.openflag)
+ self.f = self.openmethod[0](self.fname, self.openflag, cachesize=32768)
self.d = dict(q='Guido', w='van', e='Rossum', r='invented', t='Python', y='')
for k, v in self.d.iteritems():
self.f[k] = v
More information about the Python-checkins
mailing list