Commit f71de3e9 authored by Barry Warsaw's avatar Barry Warsaw

Everything worked in both the distutils distro and in Python 2.3cvs,

so merge from the bsddb-bsddb3-schizo-branch back to the trunk.
parent a6ae9a21
...@@ -44,11 +44,11 @@ except ImportError: ...@@ -44,11 +44,11 @@ except ImportError:
del sys.modules[__name__] del sys.modules[__name__]
raise raise
# bsddb3 calls it _db # bsddb3 calls it db, but provide _db for backwards compatibility
_db = _bsddb db = _db = _bsddb
__version__ = _db.__version__ __version__ = db.__version__
error = _db.DBError # So bsddb.error will mean something... error = db.DBError # So bsddb.error will mean something...
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -152,14 +152,14 @@ def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None, ...@@ -152,14 +152,14 @@ def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
cachesize=None, lorder=None, hflags=0): cachesize=None, lorder=None, hflags=0):
flags = _checkflag(flag) flags = _checkflag(flag)
d = _db.DB() d = db.DB()
d.set_flags(hflags) d.set_flags(hflags)
if cachesize is not None: d.set_cachesize(0, cachesize) if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize) if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder) if lorder is not None: d.set_lorder(lorder)
if ffactor is not None: d.set_h_ffactor(ffactor) if ffactor is not None: d.set_h_ffactor(ffactor)
if nelem is not None: d.set_h_nelem(nelem) if nelem is not None: d.set_h_nelem(nelem)
d.open(file, _db.DB_HASH, flags, mode) d.open(file, db.DB_HASH, flags, mode)
return _DBWithCursor(d) return _DBWithCursor(d)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -169,14 +169,14 @@ def btopen(file, flag='c', mode=0666, ...@@ -169,14 +169,14 @@ def btopen(file, flag='c', mode=0666,
pgsize=None, lorder=None): pgsize=None, lorder=None):
flags = _checkflag(flag) flags = _checkflag(flag)
d = _db.DB() d = db.DB()
if cachesize is not None: d.set_cachesize(0, cachesize) if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize) if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder) if lorder is not None: d.set_lorder(lorder)
d.set_flags(btflags) d.set_flags(btflags)
if minkeypage is not None: d.set_bt_minkey(minkeypage) if minkeypage is not None: d.set_bt_minkey(minkeypage)
if maxkeypage is not None: d.set_bt_maxkey(maxkeypage) if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
d.open(file, _db.DB_BTREE, flags, mode) d.open(file, db.DB_BTREE, flags, mode)
return _DBWithCursor(d) return _DBWithCursor(d)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -187,7 +187,7 @@ def rnopen(file, flag='c', mode=0666, ...@@ -187,7 +187,7 @@ def rnopen(file, flag='c', mode=0666,
rlen=None, delim=None, source=None, pad=None): rlen=None, delim=None, source=None, pad=None):
flags = _checkflag(flag) flags = _checkflag(flag)
d = _db.DB() d = db.DB()
if cachesize is not None: d.set_cachesize(0, cachesize) if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize) if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder) if lorder is not None: d.set_lorder(lorder)
...@@ -196,7 +196,7 @@ def rnopen(file, flag='c', mode=0666, ...@@ -196,7 +196,7 @@ def rnopen(file, flag='c', mode=0666,
if rlen is not None: d.set_re_len(rlen) if rlen is not None: d.set_re_len(rlen)
if source is not None: d.set_re_source(source) if source is not None: d.set_re_source(source)
if pad is not None: d.set_re_pad(pad) if pad is not None: d.set_re_pad(pad)
d.open(file, _db.DB_RECNO, flags, mode) d.open(file, db.DB_RECNO, flags, mode)
return _DBWithCursor(d) return _DBWithCursor(d)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -204,18 +204,18 @@ def rnopen(file, flag='c', mode=0666, ...@@ -204,18 +204,18 @@ def rnopen(file, flag='c', mode=0666,
def _checkflag(flag): def _checkflag(flag):
if flag == 'r': if flag == 'r':
flags = _db.DB_RDONLY flags = db.DB_RDONLY
elif flag == 'rw': elif flag == 'rw':
flags = 0 flags = 0
elif flag == 'w': elif flag == 'w':
flags = _db.DB_CREATE flags = db.DB_CREATE
elif flag == 'c': elif flag == 'c':
flags = _db.DB_CREATE flags = db.DB_CREATE
elif flag == 'n': elif flag == 'n':
flags = _db.DB_CREATE | _db.DB_TRUNCATE flags = db.DB_CREATE | db.DB_TRUNCATE
else: else:
raise error, "flags should be one of 'r', 'w', 'c' or 'n'" raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
return flags | _db.DB_THREAD return flags | db.DB_THREAD
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -231,7 +231,7 @@ try: ...@@ -231,7 +231,7 @@ try:
import thread import thread
del thread del thread
except ImportError: except ImportError:
_db.DB_THREAD = 0 db.DB_THREAD = 0
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -30,7 +30,12 @@ storage. ...@@ -30,7 +30,12 @@ storage.
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import cPickle import cPickle
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
#------------------------------------------------------------------------ #------------------------------------------------------------------------
......
This diff is collapsed.
...@@ -26,7 +26,12 @@ ...@@ -26,7 +26,12 @@
# #
from time import sleep as _sleep from time import sleep as _sleep
from bsddb import _db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
# always sleep at least N seconds between retrys # always sleep at least N seconds between retrys
_deadlock_MinSleepTime = 1.0/64 _deadlock_MinSleepTime = 1.0/64
...@@ -60,7 +65,7 @@ def DeadlockWrap(function, *_args, **_kwargs): ...@@ -60,7 +65,7 @@ def DeadlockWrap(function, *_args, **_kwargs):
while 1: while 1:
try: try:
return function(*_args, **_kwargs) return function(*_args, **_kwargs)
except _db.DBLockDeadlockError: except db.DBLockDeadlockError:
if _deadlock_VerboseFile: if _deadlock_VerboseFile:
_deadlock_VerboseFile.write( _deadlock_VerboseFile.write(
'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime) 'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
......
...@@ -16,7 +16,12 @@ if 'silent' in sys.argv: # take care of old flag, just in case ...@@ -16,7 +16,12 @@ if 'silent' in sys.argv: # take care of old flag, just in case
def print_versions(): def print_versions():
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
print print
print '-=' * 38 print '-=' * 38
print db.DB_VERSION_STRING print db.DB_VERSION_STRING
......
...@@ -16,7 +16,12 @@ except ImportError: ...@@ -16,7 +16,12 @@ except ImportError:
import unittest import unittest
from test_all import verbose from test_all import verbose
from bsddb import db, dbshelve try:
# For Python 2.3
from bsddb import db, dbshelve
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, dbshelve
#---------------------------------------------------------------------- #----------------------------------------------------------------------
......
...@@ -12,7 +12,12 @@ import tempfile ...@@ -12,7 +12,12 @@ import tempfile
from pprint import pprint from pprint import pprint
import unittest import unittest
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
from test_all import verbose from test_all import verbose
......
...@@ -4,13 +4,18 @@ regression test suite. ...@@ -4,13 +4,18 @@ regression test suite.
""" """
import sys, os, string import sys, os, string
from bsddb import hashopen, btopen, rnopen
import bsddb import bsddb
import unittest import unittest
import tempfile import tempfile
from test_all import verbose from test_all import verbose
try:
# For Python 2.3
from bsddb import db, hashopen, btopen, rnopen
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, hashopen, btopen, rnopen
class CompatibilityTestCase(unittest.TestCase): class CompatibilityTestCase(unittest.TestCase):
...@@ -126,7 +131,7 @@ class CompatibilityTestCase(unittest.TestCase): ...@@ -126,7 +131,7 @@ class CompatibilityTestCase(unittest.TestCase):
if verbose: print "truth test: true" if verbose: print "truth test: true"
else: else:
if verbose: print "truth test: false" if verbose: print "truth test: false"
except bsddb.error: except db.DBError:
pass pass
else: else:
self.fail("Exception expected") self.fail("Exception expected")
......
...@@ -3,7 +3,12 @@ import sys, os, string ...@@ -3,7 +3,12 @@ import sys, os, string
import unittest import unittest
import glob import glob
from bsddb import db, dbobj try:
# For Python 2.3
from bsddb import db, dbobj
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, dbobj
#---------------------------------------------------------------------- #----------------------------------------------------------------------
......
...@@ -8,7 +8,12 @@ from pprint import pprint ...@@ -8,7 +8,12 @@ from pprint import pprint
from types import * from types import *
import unittest import unittest
from bsddb import dbshelve, db try:
# For Python 2.3
from bsddb import db, dbshelve
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, dbshelve
from test_all import verbose from test_all import verbose
......
...@@ -30,7 +30,12 @@ except ImportError: ...@@ -30,7 +30,12 @@ except ImportError:
import unittest import unittest
from test_all import verbose from test_all import verbose
from bsddb import db, dbtables try:
# For Python 2.3
from bsddb import db, dbtables
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, dbtables
......
...@@ -8,7 +8,12 @@ import tempfile ...@@ -8,7 +8,12 @@ import tempfile
import glob import glob
import unittest import unittest
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
from test_all import verbose from test_all import verbose
......
...@@ -7,7 +7,12 @@ import tempfile ...@@ -7,7 +7,12 @@ import tempfile
from pprint import pprint from pprint import pprint
import unittest import unittest
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
from test_all import verbose from test_all import verbose
......
...@@ -18,7 +18,12 @@ except ImportError: ...@@ -18,7 +18,12 @@ except ImportError:
import unittest import unittest
from test_all import verbose from test_all import verbose
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
#---------------------------------------------------------------------- #----------------------------------------------------------------------
......
...@@ -5,8 +5,12 @@ import os ...@@ -5,8 +5,12 @@ import os
import sys import sys
import unittest import unittest
from bsddb import db try:
from bsddb import dbshelve # For Python 2.3
from bsddb import db, dbshelve
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, dbshelve
from test.test_support import verbose from test.test_support import verbose
......
...@@ -7,7 +7,12 @@ import tempfile ...@@ -7,7 +7,12 @@ import tempfile
from pprint import pprint from pprint import pprint
import unittest import unittest
from bsddb import db try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
from test_all import verbose from test_all import verbose
......
...@@ -8,9 +8,15 @@ import tempfile ...@@ -8,9 +8,15 @@ import tempfile
from pprint import pprint from pprint import pprint
import unittest import unittest
from bsddb import db
from test_all import verbose from test_all import verbose
try:
# For Python 2.3
from bsddb import db
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
......
...@@ -26,7 +26,14 @@ except ImportError: ...@@ -26,7 +26,14 @@ except ImportError:
import unittest import unittest
from test_all import verbose from test_all import verbose
from bsddb import db, dbutils
try:
# For Python 2.3
from bsddb import db, dbutils
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, dbutils
#---------------------------------------------------------------------- #----------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment