]> granicus.if.org Git - python/commitdiff
Fix compatibility for earlier versions of Python (than 2.3), which
authorBarry Warsaw <barry@python.org>
Sat, 8 Feb 2003 03:18:58 +0000 (03:18 +0000)
committerBarry Warsaw <barry@python.org>
Sat, 8 Feb 2003 03:18:58 +0000 (03:18 +0000)
doesn't have UserDict.DictMixin.

Lib/bsddb/dbobj.py
Lib/bsddb/dbshelve.py

index f274d562ce85b388774dee204744b6273ec0670d..889e5544e79b8b4a68387e0af3337ef898f9dedb 100644 (file)
 #
 
 import db
-from UserDict import DictMixin
+
+try:
+    from UserDict import DictMixin
+except ImportError:
+    # DictMixin is new in Python 2.3
+    class DictMixin: pass
 
 class DBEnv:
     def __init__(self, *args, **kwargs):
index 34dc607dc9f04af41059816e6ad851d640c64342..efaa0039bc199fdd1a6782583e6b98a651e40c7f 100644 (file)
@@ -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)