[Python-checkins] r45320 - in python/branches/release24-maint/Lib: bsddb/__init__.py test/test_bsddb.py
gregory.p.smith
python-checkins at python.org
Wed Apr 12 22:37:59 CEST 2006
Author: gregory.p.smith
Date: Wed Apr 12 22:37:58 2006
New Revision: 45320
Modified:
python/branches/release24-maint/Lib/bsddb/__init__.py
python/branches/release24-maint/Lib/test/test_bsddb.py
Log:
backport 43519. fixes SF bug 1117761.
bsddb.*open() methods were failing when the cachesize parameter was
supplied.
Modified: python/branches/release24-maint/Lib/bsddb/__init__.py
==============================================================================
--- python/branches/release24-maint/Lib/bsddb/__init__.py (original)
+++ python/branches/release24-maint/Lib/bsddb/__init__.py Wed Apr 12 22:37:58 2006
@@ -288,10 +288,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)
@@ -306,9 +305,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)
@@ -325,9 +323,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)
@@ -340,8 +337,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/branches/release24-maint/Lib/test/test_bsddb.py
==============================================================================
--- python/branches/release24-maint/Lib/test/test_bsddb.py (original)
+++ python/branches/release24-maint/Lib/test/test_bsddb.py Wed Apr 12 22:37:58 2006
@@ -13,7 +13,7 @@
class TestBSDDB(unittest.TestCase):
def setUp(self):
- self.f = self.openmethod[0](self.fname, 'c')
+ self.f = self.openmethod[0](self.fname, 'c', 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