SOURCES (AC-branch): python-bsddb.patch (NEW) - backport bsddb3-4....
glen
glen at pld-linux.org
Sun Apr 13 12:37:50 CEST 2008
Author: glen Date: Sun Apr 13 10:37:50 2008 GMT
Module: SOURCES Tag: AC-branch
---- Log message:
- backport bsddb3-4.6.3 for compiling with db 4.5
---- Files affected:
SOURCES:
python-bsddb.patch (NONE -> 1.1.2.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/python-bsddb.patch
diff -u /dev/null SOURCES/python-bsddb.patch:1.1.2.1
--- /dev/null Sun Apr 13 12:37:50 2008
+++ SOURCES/python-bsddb.patch Sun Apr 13 12:37:45 2008
@@ -0,0 +1,8577 @@
+--- Python-2.4.5/Lib/bsddb/__init__.py 2006-04-12 23:37:58.000000000 +0300
++++ bsddb3-4.6.3/Lib/bsddb/__init__.py 2008-03-20 02:53:03.000000000 +0200
+@@ -33,7 +33,10 @@
+ #----------------------------------------------------------------------
+
+
+-"""Support for BerkeleyDB 3.2 through 4.2.
++"""Support for Berkeley DB 3.3 through 4.6 with a simple interface.
++
++For the full featured object oriented interface use the bsddb.db module
++instead. It mirrors the Oracle Berkeley DB C API.
+ """
+
+ try:
+@@ -43,8 +46,10 @@
+ # python as bsddb._bsddb.
+ import _pybsddb
+ _bsddb = _pybsddb
++ from bsddb3.dbutils import DeadlockWrap as _DeadlockWrap
+ else:
+ import _bsddb
++ from bsddb.dbutils import DeadlockWrap as _DeadlockWrap
+ except ImportError:
+ # Remove ourselves from sys.modules
+ import sys
+@@ -70,7 +75,7 @@
+ exec """
+ class _iter_mixin(UserDict.DictMixin):
+ def _make_iter_cursor(self):
+- cur = self.db.cursor()
++ cur = _DeadlockWrap(self.db.cursor)
+ key = id(cur)
+ self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key))
+ return cur
+@@ -90,19 +95,19 @@
+
+ # since we're only returning keys, we call the cursor
+ # methods with flags=0, dlen=0, dofs=0
+- key = cur.first(0,0,0)[0]
++ key = _DeadlockWrap(cur.first, 0,0,0)[0]
+ yield key
+
+ next = cur.next
+ while 1:
+ try:
+- key = next(0,0,0)[0]
++ key = _DeadlockWrap(next, 0,0,0)[0]
+ yield key
+ except _bsddb.DBCursorClosedError:
+ cur = self._make_iter_cursor()
+ # FIXME-20031101-greg: race condition. cursor could
+ # be closed by another thread before this call.
+- cur.set(key,0,0,0)
++ _DeadlockWrap(cur.set, key,0,0,0)
+ next = cur.next
+ except _bsddb.DBNotFoundError:
+ return
+@@ -111,30 +116,29 @@
+ return
+
+ def iteritems(self):
++ if not self.db:
++ return
+ try:
+- try:
+- cur = self._make_iter_cursor()
+- except AttributeError:
+- return
++ cur = self._make_iter_cursor()
+
+ # FIXME-20031102-greg: race condition. cursor could
+ # be closed by another thread before this call.
+
+- kv = cur.first()
++ kv = _DeadlockWrap(cur.first)
+ key = kv[0]
+ yield kv
+
+ next = cur.next
+ while 1:
+ try:
+- kv = next()
++ kv = _DeadlockWrap(next)
+ key = kv[0]
+ yield kv
+ except _bsddb.DBCursorClosedError:
+ cur = self._make_iter_cursor()
+ # FIXME-20031101-greg: race condition. cursor could
+ # be closed by another thread before this call.
+- cur.set(key,0,0,0)
++ _DeadlockWrap(cur.set, key,0,0,0)
+ next = cur.next
+ except _bsddb.DBNotFoundError:
+ return
+@@ -178,13 +182,13 @@
+
+ def _checkCursor(self):
+ if self.dbc is None:
+- self.dbc = self.db.cursor()
++ self.dbc = _DeadlockWrap(self.db.cursor)
+ if self.saved_dbc_key is not None:
+- self.dbc.set(self.saved_dbc_key)
++ _DeadlockWrap(self.dbc.set, self.saved_dbc_key)
+ self.saved_dbc_key = None
+
+ # This method is needed for all non-cursor DB calls to avoid
+- # BerkeleyDB deadlocks (due to being opened with DB_INIT_LOCK
++ # Berkeley DB deadlocks (due to being opened with DB_INIT_LOCK
+ # and DB_THREAD to be thread safe) when intermixing database
+ # operations that use the cursor internally with those that don't.
+ def _closeCursors(self, save=1):
+@@ -193,15 +197,15 @@
+ self.dbc = None
+ if save:
+ try:
+- self.saved_dbc_key = c.current(0,0,0)[0]
++ self.saved_dbc_key = _DeadlockWrap(c.current, 0,0,0)[0]
+ except db.DBError:
+ pass
+- c.close()
++ _DeadlockWrap(c.close)
+ del c
+ for cref in self._cursor_refs.values():
+ c = cref()
+ if c is not None:
+- c.close()
++ _DeadlockWrap(c.close)
+
+ def _checkOpen(self):
+ if self.db is None:
+@@ -212,73 +216,81 @@
+
+ def __len__(self):
+ self._checkOpen()
+- return len(self.db)
++ return _DeadlockWrap(lambda: len(self.db)) # len(self.db)
+
+ def __getitem__(self, key):
+ self._checkOpen()
+- return self.db[key]
++ return _DeadlockWrap(lambda: self.db[key]) # self.db[key]
+
+ def __setitem__(self, key, value):
+ self._checkOpen()
+ self._closeCursors()
+- self.db[key] = value
++ def wrapF():
++ self.db[key] = value
++ _DeadlockWrap(wrapF) # self.db[key] = value
+
+ def __delitem__(self, key):
+ self._checkOpen()
+ self._closeCursors()
+- del self.db[key]
++ def wrapF():
++ del self.db[key]
++ _DeadlockWrap(wrapF) # del self.db[key]
+
+ def close(self):
+ self._closeCursors(save=0)
+ if self.dbc is not None:
+- self.dbc.close()
++ _DeadlockWrap(self.dbc.close)
+ v = 0
+ if self.db is not None:
+- v = self.db.close()
++ v = _DeadlockWrap(self.db.close)
+ self.dbc = None
+ self.db = None
+ return v
+
+ def keys(self):
+ self._checkOpen()
+- return self.db.keys()
++ return _DeadlockWrap(self.db.keys)
+
+ def has_key(self, key):
+ self._checkOpen()
+- return self.db.has_key(key)
++ return _DeadlockWrap(self.db.has_key, key)
+
+ def set_location(self, key):
+ self._checkOpen()
+ self._checkCursor()
+- return self.dbc.set_range(key)
++ return _DeadlockWrap(self.dbc.set_range, key)
+
+ def next(self):
+ self._checkOpen()
+ self._checkCursor()
+- rv = self.dbc.next()
++ rv = _DeadlockWrap(self.dbc.next)
+ return rv
+
+ def previous(self):
+ self._checkOpen()
+ self._checkCursor()
+- rv = self.dbc.prev()
++ rv = _DeadlockWrap(self.dbc.prev)
+ return rv
+
+ def first(self):
+ self._checkOpen()
++ # fix 1725856: don't needlessly try to restore our cursor position
++ self.saved_dbc_key = None
+ self._checkCursor()
+- rv = self.dbc.first()
++ rv = _DeadlockWrap(self.dbc.first)
+ return rv
+
+ def last(self):
+ self._checkOpen()
++ # fix 1725856: don't needlessly try to restore our cursor position
++ self.saved_dbc_key = None
+ self._checkCursor()
+- rv = self.dbc.last()
++ rv = _DeadlockWrap(self.dbc.last)
+ return rv
+
+ def sync(self):
+ self._checkOpen()
+- return self.db.sync()
++ return _DeadlockWrap(self.db.sync)
+
+
+ #----------------------------------------------------------------------
+@@ -344,6 +356,7 @@
+ e.set_cachesize(0, cachesize)
+ else:
+ raise error, "cachesize must be >= 20480"
++ e.set_lk_detect(db.DB_LOCK_DEFAULT)
+ e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL)
+ return e
+
+@@ -359,9 +372,9 @@
+ elif flag == 'n':
+ flags = db.DB_CREATE
+ #flags = db.DB_CREATE | db.DB_TRUNCATE
+- # we used db.DB_TRUNCATE flag for this before but BerkeleyDB
++ # we used db.DB_TRUNCATE flag for this before but Berkeley DB
+ # 4.2.52 changed to disallowed truncate with txn environments.
+- if os.path.isfile(file):
++ if file is not None and os.path.isfile(file):
+ os.unlink(file)
+ else:
+ raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
+@@ -372,10 +385,10 @@
+
+ # This is a silly little hack that allows apps to continue to use the
+ # DB_THREAD flag even on systems without threads without freaking out
+-# BerkeleyDB.
++# Berkeley DB.
+ #
+ # This assumes that if Python was built with thread support then
+-# BerkeleyDB was too.
++# Berkeley DB was too.
+
+ try:
+ import thread
+@@ -385,5 +398,4 @@
+ except ImportError:
+ db.DB_THREAD = 0
+
+-
+ #----------------------------------------------------------------------
+--- Python-2.4.5/Lib/bsddb/db.py 2003-09-21 03:08:14.000000000 +0300
++++ bsddb3-4.6.3/Lib/bsddb/db.py 2008-03-20 02:53:12.000000000 +0200
+@@ -37,7 +37,7 @@
+ # case we ever want to augment the stuff in _db in any way. For now
+ # it just simply imports everything from _db.
+
+-if __name__[:len('bsddb3.')] == 'bsddb3.':
++if __name__.startswith('bsddb3.'):
+ # import _pybsddb binary as it should be the more recent version from
+ # a standalone pybsddb addon package than the version included with
+ # python as bsddb._bsddb.
+@@ -48,4 +48,4 @@
+ from _bsddb import __version__
+
+ if version() < (3, 2, 0):
+- raise ImportError, "correct BerkeleyDB symbols not found. Perhaps python was statically linked with an older version?"
++ raise ImportError, "correct Berkeley DB symbols not found. Perhaps python was statically linked with an older version?"
+--- Python-2.4.5/Lib/bsddb/dbobj.py 2004-06-28 07:06:49.000000000 +0300
++++ bsddb3-4.6.3/Lib/bsddb/dbobj.py 2008-03-06 19:19:25.000000000 +0200
+@@ -55,8 +55,9 @@
+ return apply(self._cobj.set_lg_max, args, kwargs)
+ def set_lk_detect(self, *args, **kwargs):
+ return apply(self._cobj.set_lk_detect, args, kwargs)
+- def set_lk_max(self, *args, **kwargs):
+- return apply(self._cobj.set_lk_max, args, kwargs)
++ if db.version() < (4,5):
++ def set_lk_max(self, *args, **kwargs):
++ return apply(self._cobj.set_lk_max, args, kwargs)
+ def set_lk_max_locks(self, *args, **kwargs):
+ return apply(self._cobj.set_lk_max_locks, args, kwargs)
+ def set_lk_max_lockers(self, *args, **kwargs):
+@@ -77,6 +78,8 @@
+ return apply(self._cobj.txn_stat, args, kwargs)
+ def set_tx_max(self, *args, **kwargs):
+ return apply(self._cobj.set_tx_max, args, kwargs)
++ def set_tx_timestamp(self, *args, **kwargs):
++ return apply(self._cobj.set_tx_timestamp, args, kwargs)
+ def lock_detect(self, *args, **kwargs):
+ return apply(self._cobj.lock_detect, args, kwargs)
+ def lock_get(self, *args, **kwargs):
+@@ -89,9 +92,14 @@
+ return apply(self._cobj.lock_stat, args, kwargs)
+ def log_archive(self, *args, **kwargs):
+ return apply(self._cobj.log_archive, args, kwargs)
++
+ def set_get_returns_none(self, *args, **kwargs):
+ return apply(self._cobj.set_get_returns_none, args, kwargs)
+
++ if db.version() >= (4,0):
++ def log_stat(self, *args, **kwargs):
++ return apply(self._cobj.log_stat, args, kwargs)
++
+ if db.version() >= (4,1):
+ def dbremove(self, *args, **kwargs):
+ return apply(self._cobj.dbremove, args, kwargs)
+@@ -100,6 +108,10 @@
+ def set_encrypt(self, *args, **kwargs):
+ return apply(self._cobj.set_encrypt, args, kwargs)
+
++ if db.version() >= (4,4):
++ def lsn_reset(self, *args, **kwargs):
++ return apply(self._cobj.lsn_reset, args, kwargs)
++
+
+ class DB(DictMixin):
+ def __init__(self, dbenv, *args, **kwargs):
+@@ -164,6 +176,8 @@
+ return apply(self._cobj.rename, args, kwargs)
+ def set_bt_minkey(self, *args, **kwargs):
+ return apply(self._cobj.set_bt_minkey, args, kwargs)
++ def set_bt_compare(self, *args, **kwargs):
++ return apply(self._cobj.set_bt_compare, args, kwargs)
+ def set_cachesize(self, *args, **kwargs):
+ return apply(self._cobj.set_cachesize, args, kwargs)
+ def set_flags(self, *args, **kwargs):
+@@ -204,3 +218,37 @@
+ if db.version() >= (4,1):
+ def set_encrypt(self, *args, **kwargs):
+ return apply(self._cobj.set_encrypt, args, kwargs)
++
++
++class DBSequence:
++ def __init__(self, *args, **kwargs):
++ self._cobj = apply(db.DBSequence, args, kwargs)
++
++ def close(self, *args, **kwargs):
++ return apply(self._cobj.close, args, kwargs)
++ def get(self, *args, **kwargs):
++ return apply(self._cobj.get, args, kwargs)
++ def get_dbp(self, *args, **kwargs):
++ return apply(self._cobj.get_dbp, args, kwargs)
++ def get_key(self, *args, **kwargs):
++ return apply(self._cobj.get_key, args, kwargs)
++ def init_value(self, *args, **kwargs):
++ return apply(self._cobj.init_value, args, kwargs)
++ def open(self, *args, **kwargs):
++ return apply(self._cobj.open, args, kwargs)
++ def remove(self, *args, **kwargs):
++ return apply(self._cobj.remove, args, kwargs)
++ def stat(self, *args, **kwargs):
++ return apply(self._cobj.stat, args, kwargs)
++ def set_cachesize(self, *args, **kwargs):
++ return apply(self._cobj.set_cachesize, args, kwargs)
++ def set_flags(self, *args, **kwargs):
++ return apply(self._cobj.set_flags, args, kwargs)
++ def set_range(self, *args, **kwargs):
++ return apply(self._cobj.set_range, args, kwargs)
++ def get_cachesize(self, *args, **kwargs):
++ return apply(self._cobj.get_cachesize, args, kwargs)
++ def get_flags(self, *args, **kwargs):
++ return apply(self._cobj.get_flags, args, kwargs)
++ def get_range(self, *args, **kwargs):
++ return apply(self._cobj.get_range, args, kwargs)
+--- Python-2.4.5/Lib/bsddb/dbrecio.py 2004-02-12 19:35:32.000000000 +0200
++++ bsddb3-4.6.3/Lib/bsddb/dbrecio.py 2008-03-06 19:19:25.000000000 +0200
+@@ -75,7 +75,7 @@
+
+ dlen = newpos - self.pos
+
+- r = self.db.get(key, txn=self.txn, dlen=dlen, doff=self.pos)
++ r = self.db.get(self.key, txn=self.txn, dlen=dlen, doff=self.pos)
+ self.pos = newpos
+ return r
+
+@@ -121,7 +121,7 @@
+ "Negative size not allowed")
+ elif size < self.pos:
+ self.pos = size
+- self.db.put(key, "", txn=self.txn, dlen=self.len-size, doff=size)
++ self.db.put(self.key, "", txn=self.txn, dlen=self.len-size, doff=size)
+
+ def write(self, s):
+ if self.closed:
+@@ -131,7 +131,7 @@
+ self.buflist.append('\0'*(self.pos - self.len))
+ self.len = self.pos
+ newpos = self.pos + len(s)
+- self.db.put(key, s, txn=self.txn, dlen=len(s), doff=self.pos)
++ self.db.put(self.key, s, txn=self.txn, dlen=len(s), doff=self.pos)
+ self.pos = newpos
+
+ def writelines(self, list):
+--- Python-2.4.5/Lib/bsddb/dbshelve.py 2004-03-16 20:50:26.000000000 +0200
++++ bsddb3-4.6.3/Lib/bsddb/dbshelve.py 2008-03-07 01:15:34.000000000 +0200
+@@ -30,12 +30,30 @@
+ #------------------------------------------------------------------------
+
+ import cPickle
+-try:
++import db
++import sys
++
++#At version 2.3 cPickle switched to using protocol instead of bin and
++#DictMixin was added
++if sys.version_info[:3] >= (2, 3, 0):
++ HIGHEST_PROTOCOL = cPickle.HIGHEST_PROTOCOL
++# In python 2.3.*, "cPickle.dumps" accepts no
++# named parameters. "pickle.dumps" accepts them,
++# so this seems a bug.
++ if sys.version_info[:3] < (2, 4, 0):
++ def _dumps(object, protocol):
++ return cPickle.dumps(object, protocol)
++ else :
++ def _dumps(object, protocol):
++ return cPickle.dumps(object, protocol=protocol)
++
+ from UserDict import DictMixin
+-except ImportError:
+- # DictMixin is new in Python 2.3
++
++else:
++ HIGHEST_PROTOCOL = None
++ def _dumps(object, protocol):
++ return cPickle.dumps(object, bin=protocol)
+ class DictMixin: pass
+-import db
+
+ #------------------------------------------------------------------------
+
+@@ -75,13 +93,20 @@
+
+ #---------------------------------------------------------------------------
+
++class DBShelveError(db.DBError): pass
++
++
+ class DBShelf(DictMixin):
+ """A shelf to hold pickled objects, built upon a bsddb DB object. It
+ automatically pickles/unpickles data objects going to/from the DB.
+ """
+ def __init__(self, dbenv=None):
+ self.db = db.DB(dbenv)
+- self.binary = 1
++ self._closed = True
++ if HIGHEST_PROTOCOL:
++ self.protocol = HIGHEST_PROTOCOL
++ else:
++ self.protocol = 1
+
+
+ def __del__(self):
+@@ -108,7 +133,7 @@
+
+
+ def __setitem__(self, key, value):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ self.db[key] = data
+
+
+@@ -123,6 +148,23 @@
+ return self.db.keys()
+
+
++ def open(self, *args, **kwargs):
++ self.db.open(*args, **kwargs)
++ self._closed = False
++
++
++ def close(self, *args, **kwargs):
++ self.db.close(*args, **kwargs)
++ self._closed = True
++
++
++ def __repr__(self):
++ if self._closed:
++ return '<DBShelf @ 0x%x - closed>' % (id(self))
++ else:
++ return repr(dict(self.iteritems()))
++
++
+ def items(self, txn=None):
+ if txn != None:
+ items = self.db.items(txn)
+@@ -146,14 +188,13 @@
+ # Other methods
+
+ def __append(self, value, txn=None):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ return self.db.append(data, txn)
+
+ def append(self, value, txn=None):
+- if self.get_type() != db.DB_RECNO:
+- self.append = self.__append
+- return self.append(value, txn=txn)
+- raise db.DBError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
++ if self.get_type() == db.DB_RECNO:
++ return self.__append(value, txn=txn)
++ raise DBShelveError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
+
+
+ def associate(self, secondaryDB, callback, flags=0):
+@@ -177,19 +218,19 @@
+ # so it doesn't need unpickled.
+
+ def get_both(self, key, value, txn=None, flags=0):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ data = self.db.get(key, data, txn, flags)
+ return cPickle.loads(data)
+
+
+ def cursor(self, txn=None, flags=0):
+ c = DBShelfCursor(self.db.cursor(txn, flags))
+- c.binary = self.binary
++ c.protocol = self.protocol
+ return c
+
+
+ def put(self, key, value, txn=None, flags=0):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ return self.db.put(key, data, txn, flags)
+
+
+@@ -225,11 +266,13 @@
+ #----------------------------------------------
+
+ def dup(self, flags=0):
+- return DBShelfCursor(self.dbc.dup(flags))
++ c = DBShelfCursor(self.dbc.dup(flags))
++ c.protocol = self.protocol
++ return c
+
+
+ def put(self, key, value, flags=0):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ return self.dbc.put(key, data, flags)
+
+
+@@ -247,7 +290,7 @@
+ return self._extract(rec)
+
+ def get_3(self, key, value, flags):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ rec = self.dbc.get(key, flags)
+ return self._extract(rec)
+
+@@ -264,7 +307,7 @@
+
+
+ def get_both(self, key, value, flags=0):
+- data = cPickle.dumps(value, self.binary)
++ data = _dumps(value, self.protocol)
+ rec = self.dbc.get_both(key, flags)
+ return self._extract(rec)
+
+--- Python-2.4.5/Lib/bsddb/dbtables.py 2004-08-08 03:54:21.000000000 +0300
++++ bsddb3-4.6.3/Lib/bsddb/dbtables.py 2008-03-20 02:53:29.000000000 +0200
+@@ -10,18 +10,18 @@
+ # software has been tested, but no warranty is expressed or
+ # implied.
+ #
+-# -- Gregory P. Smith <greg at electricrain.com>
++# -- Gregory P. Smith <greg at krypto.org>
+
+ # This provides a simple database table interface built on top of
+-# the Python BerkeleyDB 3 interface.
++# the Python Berkeley DB 3 interface.
+ #
+-_cvsid = '$Id$'
++_cvsid = '$Id$'
+
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list