summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/dbshelve.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-02-08 03:18:58 (GMT)
committerBarry Warsaw <barry@python.org>2003-02-08 03:18:58 (GMT)
commit9914227caa4f25b7442ea82cd6feab68821bb011 (patch)
treea26c22ef86bb8379b60d8c6ec4e6979ba8d1d041 /Lib/bsddb/dbshelve.py
parent07534a607bd3d2fd232323811a83279acda10885 (diff)
downloadcpython-9914227caa4f25b7442ea82cd6feab68821bb011.zip
cpython-9914227caa4f25b7442ea82cd6feab68821bb011.tar.gz
cpython-9914227caa4f25b7442ea82cd6feab68821bb011.tar.bz2
Fix compatibility for earlier versions of Python (than 2.3), which
doesn't have UserDict.DictMixin.
Diffstat (limited to 'Lib/bsddb/dbshelve.py')
-rw-r--r--Lib/bsddb/dbshelve.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py
index 34dc607..efaa003 100644
--- a/Lib/bsddb/dbshelve.py
+++ b/Lib/bsddb/dbshelve.py
@@ -30,7 +30,11 @@ storage.
#------------------------------------------------------------------------
import cPickle
-from UserDict import DictMixin
+try:
+ from UserDict import DictMixin
+except ImportError:
+ # DictMixin is new in Python 2.3
+ class DictMixin: pass
try:
# For Python 2.3
from bsddb import db
@@ -77,8 +81,7 @@ def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH,
#---------------------------------------------------------------------------
class DBShelf(DictMixin):
- """
- A shelf to hold pickled objects, built upon a bsddb DB object. It
+ """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):
@@ -91,7 +94,9 @@ class DBShelf(DictMixin):
def __getattr__(self, name):
- """Many methods we can just pass through to the DB object. (See below)"""
+ """Many methods we can just pass through to the DB object.
+ (See below)
+ """
return getattr(self.db, name)