--- shelve.py.orig 2007-12-12 12:27:07.000000000 +0200 +++ shelve.py 2007-12-12 12:44:15.000000000 +0200 @@ -73,6 +73,7 @@ __all__ = ["Shelf","BsdDbShelf","DbfilenameShelf","open"] + class Shelf(UserDict.DictMixin): """Base class for shelf implementations. @@ -81,13 +82,21 @@ """ def __init__(self, dict, protocol=None, writeback=False): - self.dict = dict + self._dict = dict if protocol is None: protocol = 0 self._protocol = protocol self.writeback = writeback self.cache = {} + def getdict(self): + if self._dict is None: + raise IOError, 'shelf has been closed' + else: + return self._dict + + dict = property(getdict) + def keys(self): return self.dict.keys() @@ -136,7 +145,8 @@ self.dict.close() except AttributeError: pass - self.dict = 0 + + self._dict = None def __del__(self): if not hasattr(self, 'writeback'):