I can't test this directly on my build, so letting the buildbots do it for me.
If it fails, expect a reversion.
#----------------------------------------------------------------------
-import sys, os, UserDict
+import sys, os, collections
from weakref import ref
-class _iter_mixin(UserDict.DictMixin):
+class _iter_mixin(collections.MutableMapping):
def _make_iter_cursor(self):
cur = _DeadlockWrap(self.db.cursor)
key = id(cur)
def _cursor_refs(self):
return self.db._cursor_refs
-class StringKeys(UserDict.DictMixin, _ExposedProperties):
+class StringKeys(collections.MutableMapping, _ExposedProperties):
"""Wrapper around DB object that automatically encodes
all keys as UTF-8; the keys must be strings."""
def sync(self):
return self.db.sync()
-class StringValues(UserDict.DictMixin, _ExposedProperties):
+class StringValues(collections.MutableMapping, _ExposedProperties):
"""Wrapper around DB object that automatically encodes
and decodes all values as UTF-8; input values must be strings."""
from . import db
try:
- from UserDict import DictMixin
+ from collections import MutableMapping
except ImportError:
- # DictMixin is new in Python 2.3
- class DictMixin: pass
+ class MutableMapping: pass
class DBEnv:
def __init__(self, *args, **kwargs):
return 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 = db.DB(dbenv._cobj, *args, **kwargs)
self._cobj[key] = value
def __delitem__(self, arg):
del self._cobj[arg]
+ def __iter__(self):
+ return iter(self.keys())
def append(self, *args, **kwargs):
return self._cobj.append(*args, **kwargs)
HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL
def _dumps(object, protocol):
return pickle.dumps(object, protocol=protocol)
- from UserDict import DictMixin
+ from collections import MutableMapping
else:
HIGHEST_PROTOCOL = None
def _dumps(object, protocol):
return pickle.dumps(object, bin=protocol)
- class DictMixin: pass
+ class MutableMapping: pass
from . import db
class DBShelveError(db.DBError): pass
-class DBShelf(DictMixin):
+class DBShelf(MutableMapping):
"""A shelf to hold pickled objects, built upon a bsddb DB object. It
automatically pickles/unpickles data objects going to/from the DB.
"""
else:
return self.db.keys()
+ def __iter__(self):
+ return iter(self.keys())
def open(self, *args, **kwargs):
self.db.open(*args, **kwargs)