diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-13 23:02:05 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-13 23:02:05 (GMT) |
commit | 5d743fd187f59ef792373e026f0de4ada63a3387 (patch) | |
tree | 6149a951cd6c0ecb8c17d98325a9867354eb5c55 | |
parent | 5fbf66370348d0310c2b9e477cbac099fad136a8 (diff) | |
download | cpython-5d743fd187f59ef792373e026f0de4ada63a3387.zip cpython-5d743fd187f59ef792373e026f0de4ada63a3387.tar.gz cpython-5d743fd187f59ef792373e026f0de4ada63a3387.tar.bz2 |
Fix an uncollectable reference leak in bsddb.db.DBShelf.append
-rw-r--r-- | Lib/bsddb/dbshelve.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py index 33668f4..f5f8b9a 100644 --- a/Lib/bsddb/dbshelve.py +++ b/Lib/bsddb/dbshelve.py @@ -93,6 +93,7 @@ class DBShelf(DictMixin): """ def __init__(self, dbenv=None): self.db = db.DB(dbenv) + self._closed = True if HIGHEST_PROTOCOL: self.protocol = HIGHEST_PROTOCOL else: @@ -138,6 +139,23 @@ class DBShelf(DictMixin): return self.db.keys() + def open(self, *args, **kwargs): + self.db.open(*args, **kwargs) + self._closed = False + + + def close(self, *args, **kwargs): + self.db.close(*args, **kwargs) + self._closed = True + + + def __repr__(self): + if self._closed: + return '<DBShelf @ 0x%x - closed>' % (id(self)) + else: + return repr(dict(self.iteritems())) + + def items(self, txn=None): if txn != None: items = self.db.items(txn) @@ -166,8 +184,7 @@ class DBShelf(DictMixin): def append(self, value, txn=None): if self.get_type() == db.DB_RECNO: - self.append = self.__append - return self.append(value, txn=txn) + return self.__append(value, txn=txn) raise DBShelveError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO" |