mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
bsddb module updated to version 4.7.2devel9.
This patch publishes the work done until now for Python 3.0 compatibility. Still a lot to be done. When possible, we use 3.0 features in Python 2.6, easing development and testing, and exposing internal changes to a wider audience, for better test coverage. Some mode details: http://www.jcea.es/programacion/pybsddb.htm#bsddb3-4.7.2
This commit is contained in:
parent
30e208d525
commit
c5a11fabdb
16 changed files with 1395 additions and 752 deletions
|
@ -21,13 +21,24 @@
|
|||
# added to _bsddb.c.
|
||||
#
|
||||
|
||||
import db
|
||||
import sys
|
||||
absolute_import = (sys.version_info[0] >= 3)
|
||||
if absolute_import :
|
||||
# Because this syntaxis is not valid before Python 2.5
|
||||
exec("from . import db")
|
||||
else :
|
||||
import db
|
||||
|
||||
try:
|
||||
from UserDict import DictMixin
|
||||
except ImportError:
|
||||
# DictMixin is new in Python 2.3
|
||||
class DictMixin: pass
|
||||
if sys.version_info[0:2] <= (2, 5) :
|
||||
try:
|
||||
from UserDict import DictMixin
|
||||
except ImportError:
|
||||
# DictMixin is new in Python 2.3
|
||||
class DictMixin: pass
|
||||
MutableMapping = DictMixin
|
||||
else :
|
||||
import collections
|
||||
MutableMapping = collections.MutableMapping
|
||||
|
||||
class DBEnv:
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -96,9 +107,8 @@ class DBEnv:
|
|||
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)
|
||||
def log_stat(self, *args, **kwargs):
|
||||
return apply(self._cobj.log_stat, args, kwargs)
|
||||
|
||||
if db.version() >= (4,1):
|
||||
def dbremove(self, *args, **kwargs):
|
||||
|
@ -113,7 +123,7 @@ class DBEnv:
|
|||
return apply(self._cobj.lsn_reset, args, kwargs)
|
||||
|
||||
|
||||
class DB(DictMixin):
|
||||
class DB(MutableMapping):
|
||||
def __init__(self, dbenv, *args, **kwargs):
|
||||
# give it the proper DBEnv C object that its expecting
|
||||
self._cobj = apply(db.DB, (dbenv._cobj,) + args, kwargs)
|
||||
|
@ -128,6 +138,10 @@ class DB(DictMixin):
|
|||
def __delitem__(self, arg):
|
||||
del self._cobj[arg]
|
||||
|
||||
if sys.version_info[0:2] >= (2, 6) :
|
||||
def __iter__(self) :
|
||||
return self._cobj.__iter__()
|
||||
|
||||
def append(self, *args, **kwargs):
|
||||
return apply(self._cobj.append, args, kwargs)
|
||||
def associate(self, *args, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue