Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f71de3e

Browse files
committed
Everything worked in both the distutils distro and in Python 2.3cvs,
so merge from the bsddb-bsddb3-schizo-branch back to the trunk.
1 parent a6ae9a2 commit f71de3e

18 files changed

Lines changed: 213 additions & 119 deletions

Lib/bsddb/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
del sys.modules[__name__]
4545
raise
4646

47-
# bsddb3 calls it _db
48-
_db = _bsddb
49-
__version__ = _db.__version__
47+
# bsddb3 calls it db, but provide _db for backwards compatibility
48+
db = _db = _bsddb
49+
__version__ = db.__version__
5050

51-
error = _db.DBError # So bsddb.error will mean something...
51+
error = db.DBError # So bsddb.error will mean something...
5252

5353
#----------------------------------------------------------------------
5454

@@ -152,14 +152,14 @@ def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
152152
cachesize=None, lorder=None, hflags=0):
153153

154154
flags = _checkflag(flag)
155-
d = _db.DB()
155+
d = db.DB()
156156
d.set_flags(hflags)
157157
if cachesize is not None: d.set_cachesize(0, cachesize)
158158
if pgsize is not None: d.set_pagesize(pgsize)
159159
if lorder is not None: d.set_lorder(lorder)
160160
if ffactor is not None: d.set_h_ffactor(ffactor)
161161
if nelem is not None: d.set_h_nelem(nelem)
162-
d.open(file, _db.DB_HASH, flags, mode)
162+
d.open(file, db.DB_HASH, flags, mode)
163163
return _DBWithCursor(d)
164164

165165
#----------------------------------------------------------------------
@@ -169,14 +169,14 @@ def btopen(file, flag='c', mode=0666,
169169
pgsize=None, lorder=None):
170170

171171
flags = _checkflag(flag)
172-
d = _db.DB()
172+
d = db.DB()
173173
if cachesize is not None: d.set_cachesize(0, cachesize)
174174
if pgsize is not None: d.set_pagesize(pgsize)
175175
if lorder is not None: d.set_lorder(lorder)
176176
d.set_flags(btflags)
177177
if minkeypage is not None: d.set_bt_minkey(minkeypage)
178178
if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
179-
d.open(file, _db.DB_BTREE, flags, mode)
179+
d.open(file, db.DB_BTREE, flags, mode)
180180
return _DBWithCursor(d)
181181

182182
#----------------------------------------------------------------------
@@ -187,7 +187,7 @@ def rnopen(file, flag='c', mode=0666,
187187
rlen=None, delim=None, source=None, pad=None):
188188

189189
flags = _checkflag(flag)
190-
d = _db.DB()
190+
d = db.DB()
191191
if cachesize is not None: d.set_cachesize(0, cachesize)
192192
if pgsize is not None: d.set_pagesize(pgsize)
193193
if lorder is not None: d.set_lorder(lorder)
@@ -196,26 +196,26 @@ def rnopen(file, flag='c', mode=0666,
196196
if rlen is not None: d.set_re_len(rlen)
197197
if source is not None: d.set_re_source(source)
198198
if pad is not None: d.set_re_pad(pad)
199-
d.open(file, _db.DB_RECNO, flags, mode)
199+
d.open(file, db.DB_RECNO, flags, mode)
200200
return _DBWithCursor(d)
201201

202202
#----------------------------------------------------------------------
203203

204204

205205
def _checkflag(flag):
206206
if flag == 'r':
207-
flags = _db.DB_RDONLY
207+
flags = db.DB_RDONLY
208208
elif flag == 'rw':
209209
flags = 0
210210
elif flag == 'w':
211-
flags = _db.DB_CREATE
211+
flags = db.DB_CREATE
212212
elif flag == 'c':
213-
flags = _db.DB_CREATE
213+
flags = db.DB_CREATE
214214
elif flag == 'n':
215-
flags = _db.DB_CREATE | _db.DB_TRUNCATE
215+
flags = db.DB_CREATE | db.DB_TRUNCATE
216216
else:
217217
raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
218-
return flags | _db.DB_THREAD
218+
return flags | db.DB_THREAD
219219

220220
#----------------------------------------------------------------------
221221

@@ -231,7 +231,7 @@ def _checkflag(flag):
231231
import thread
232232
del thread
233233
except ImportError:
234-
_db.DB_THREAD = 0
234+
db.DB_THREAD = 0
235235

236236

237237
#----------------------------------------------------------------------

Lib/bsddb/dbshelve.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
#------------------------------------------------------------------------
3131

3232
import cPickle
33-
from bsddb import db
33+
try:
34+
# For Python 2.3
35+
from bsddb import db
36+
except ImportError:
37+
# For earlier Pythons w/distutils pybsddb
38+
from bsddb3 import db
3439

3540
#------------------------------------------------------------------------
3641

0 commit comments

Comments
 (0)