diff options
Diffstat (limited to 'Lib/bsddb')
-rw-r--r-- | Lib/bsddb/__init__.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/dbobj.py | 4 | ||||
-rw-r--r-- | Lib/bsddb/dbshelve.py | 6 | ||||
-rw-r--r-- | Lib/bsddb/dbutils.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_all.py | 8 | ||||
-rw-r--r-- | Lib/bsddb/test/test_associate.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_basics.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_compare.py | 3 | ||||
-rw-r--r-- | Lib/bsddb/test/test_compat.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_dbshelve.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_dbtables.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_env_close.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_get_none.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_join.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_lock.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_queue.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_recno.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_sequence.py | 2 | ||||
-rw-r--r-- | Lib/bsddb/test/test_thread.py | 2 |
19 files changed, 32 insertions, 19 deletions
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py index cf32668..0eeefd1 100644 --- a/Lib/bsddb/__init__.py +++ b/Lib/bsddb/__init__.py @@ -255,6 +255,8 @@ class _DBWithCursor(_iter_mixin): self._checkOpen() return _DeadlockWrap(self.db.has_key, key) + __contains__ = has_key + def set_location(self, key): self._checkOpen() self._checkCursor() diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py index 40a51ec..346c1ad 100644 --- a/Lib/bsddb/dbobj.py +++ b/Lib/bsddb/dbobj.py @@ -21,7 +21,7 @@ # added to _bsddb.c. # -import db +from . import db try: from UserDict import DictMixin @@ -161,6 +161,8 @@ class DB(DictMixin): return self._cobj.key_range(*args, **kwargs) def has_key(self, *args, **kwargs): return self._cobj.has_key(*args, **kwargs) + def __contains__(self, key): + return self._cobj.has_key(key) def items(self, *args, **kwargs): return self._cobj.items(*args, **kwargs) def keys(self, *args, **kwargs): diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py index 5cd4a53..afc1a1a 100644 --- a/Lib/bsddb/dbshelve.py +++ b/Lib/bsddb/dbshelve.py @@ -35,7 +35,7 @@ try: except ImportError: # DictMixin is new in Python 2.3 class DictMixin: pass -import db +from . import db #------------------------------------------------------------------------ @@ -197,6 +197,10 @@ class DBShelf(DictMixin): raise NotImplementedError + def __contains__(self, key): + return self.has_key(key) + + #---------------------------------------------- # Methods allowed to pass-through to self.db # diff --git a/Lib/bsddb/dbutils.py b/Lib/bsddb/dbutils.py index 30b3cc7..0c4c1cb 100644 --- a/Lib/bsddb/dbutils.py +++ b/Lib/bsddb/dbutils.py @@ -55,7 +55,7 @@ def DeadlockWrap(function, *_args, **_kwargs): """ sleeptime = _deadlock_MinSleepTime max_retries = _kwargs.get('max_retries', -1) - if _kwargs.has_key('max_retries'): + if 'max_tries' in _kwargs: del _kwargs['max_retries'] while True: try: diff --git a/Lib/bsddb/test/test_all.py b/Lib/bsddb/test/test_all.py index ad8b1e9..0b132f4 100644 --- a/Lib/bsddb/test/test_all.py +++ b/Lib/bsddb/test/test_all.py @@ -41,8 +41,12 @@ class PrintInfoFakeTest(unittest.TestCase): # This little hack is for when this module is run as main and all the # other modules import it so they will still be able to get the right # verbose setting. It's confusing but it works. -import test_all -test_all.verbose = verbose +try: + import test_all +except ImportError: + pass +else: + test_all.verbose = verbose def suite(): diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py index 05ef83c..33a7837 100644 --- a/Lib/bsddb/test/test_associate.py +++ b/Lib/bsddb/test/test_associate.py @@ -14,7 +14,7 @@ except ImportError: have_threads = 0 import unittest -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py index d6d507f..f7f4c2d 100644 --- a/Lib/bsddb/test/test_basics.py +++ b/Lib/bsddb/test/test_basics.py @@ -20,7 +20,7 @@ except ImportError: # For Python 2.3 from bsddb import db -from test_all import verbose +from .test_all import verbose DASH = '-' diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py index 59a45ec..ccf8b83 100644 --- a/Lib/bsddb/test/test_compare.py +++ b/Lib/bsddb/test/test_compare.py @@ -3,9 +3,10 @@ TestCases for python DB Btree key comparison function. """ import sys, os, re -import test_all from cStringIO import StringIO +from . import test_all + import unittest try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_compat.py b/Lib/bsddb/test/test_compat.py index b108db4..841e01c 100644 --- a/Lib/bsddb/test/test_compat.py +++ b/Lib/bsddb/test/test_compat.py @@ -7,7 +7,7 @@ import sys, os, string import unittest import tempfile -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py index 722ee5b..bb85bf7 100644 --- a/Lib/bsddb/test/test_dbshelve.py +++ b/Lib/bsddb/test/test_dbshelve.py @@ -15,7 +15,7 @@ except ImportError: # For Python 2.3 from bsddb import db, dbshelve -from test_all import verbose +from .test_all import verbose #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py index 26e3d36..2ff93a3 100644 --- a/Lib/bsddb/test/test_dbtables.py +++ b/Lib/bsddb/test/test_dbtables.py @@ -28,7 +28,7 @@ except ImportError: import pickle import unittest -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_env_close.py b/Lib/bsddb/test/test_env_close.py index c112941..43dcabe 100644 --- a/Lib/bsddb/test/test_env_close.py +++ b/Lib/bsddb/test/test_env_close.py @@ -15,7 +15,7 @@ except ImportError: # For Python 2.3 from bsddb import db -from test_all import verbose +from .test_all import verbose # We're going to get warnings in this module about trying to close the db when # its env is already closed. Let's just ignore those. diff --git a/Lib/bsddb/test/test_get_none.py b/Lib/bsddb/test/test_get_none.py index 5f09cec..d1b69c7 100644 --- a/Lib/bsddb/test/test_get_none.py +++ b/Lib/bsddb/test/test_get_none.py @@ -14,7 +14,7 @@ except ImportError: # For Python 2.3 from bsddb import db -from test_all import verbose +from .test_all import verbose #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py index 69a1e9d..6e98b0b 100644 --- a/Lib/bsddb/test/test_join.py +++ b/Lib/bsddb/test/test_join.py @@ -13,7 +13,7 @@ except ImportError: have_threads = 0 import unittest -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py index 7d77798..53f11a8 100644 --- a/Lib/bsddb/test/test_lock.py +++ b/Lib/bsddb/test/test_lock.py @@ -15,7 +15,7 @@ except ImportError: import unittest -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_queue.py b/Lib/bsddb/test/test_queue.py index 95cf20d..4226c9e 100644 --- a/Lib/bsddb/test/test_queue.py +++ b/Lib/bsddb/test/test_queue.py @@ -14,7 +14,7 @@ except ImportError: # For Python 2.3 from bsddb import db -from test_all import verbose +from .test_all import verbose #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py index f1ea56a..170448e 100644 --- a/Lib/bsddb/test/test_recno.py +++ b/Lib/bsddb/test/test_recno.py @@ -8,7 +8,7 @@ import tempfile from pprint import pprint import unittest -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py index 979f858..48631a3 100644 --- a/Lib/bsddb/test/test_sequence.py +++ b/Lib/bsddb/test/test_sequence.py @@ -10,7 +10,7 @@ try: except ImportError: from bsddb import db -from test_all import verbose +from .test_all import verbose class DBSequenceTest(unittest.TestCase): diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py index 31964f0..f187413 100644 --- a/Lib/bsddb/test/test_thread.py +++ b/Lib/bsddb/test/test_thread.py @@ -31,7 +31,7 @@ except NameError: pass import unittest -from test_all import verbose +from .test_all import verbose try: # For Pythons w/distutils pybsddb |