diff options
author | Jesus Cea <jcea@jcea.es> | 2008-07-23 11:38:42 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2008-07-23 11:38:42 (GMT) |
commit | c5a11fabdb03d032f278f86e600bcdaafdb5d783 (patch) | |
tree | e7db234112c7ac06aebe9c1e7833b0dd4168c664 /Lib/bsddb/dbobj.py | |
parent | 30e208d525cd472446feb91b774cf472e7122918 (diff) | |
download | cpython-c5a11fabdb03d032f278f86e600bcdaafdb5d783.zip cpython-c5a11fabdb03d032f278f86e600bcdaafdb5d783.tar.gz cpython-c5a11fabdb03d032f278f86e600bcdaafdb5d783.tar.bz2 |
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
Diffstat (limited to 'Lib/bsddb/dbobj.py')
-rw-r--r-- | Lib/bsddb/dbobj.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py index b74ee72..f6b1d7f 100644 --- a/Lib/bsddb/dbobj.py +++ b/Lib/bsddb/dbobj.py @@ -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): |