mirror of
https://github.com/python/cpython
synced 2024-10-08 20:10:00 +00:00
Fix compatibility for earlier versions of Python (than 2.3), which
doesn't have UserDict.DictMixin.
This commit is contained in:
parent
07534a607b
commit
9914227caa
|
@ -16,7 +16,12 @@
|
|||
#
|
||||
|
||||
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):
|
||||
|
|
|
@ -30,7 +30,11 @@
|
|||
#------------------------------------------------------------------------
|
||||
|
||||
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 @@ def __del__(self):
|
|||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue