[Python-checkins] r58450 - python/trunk/Lib/bsddb/dbshelve.py
gregory.p.smith
python-checkins at python.org
Sun Oct 14 01:02:05 CEST 2007
Author: gregory.p.smith
Date: Sun Oct 14 01:02:05 2007
New Revision: 58450
Modified:
python/trunk/Lib/bsddb/dbshelve.py
Log:
Fix an uncollectable reference leak in bsddb.db.DBShelf.append
Modified: python/trunk/Lib/bsddb/dbshelve.py
==============================================================================
--- python/trunk/Lib/bsddb/dbshelve.py (original)
+++ python/trunk/Lib/bsddb/dbshelve.py Sun Oct 14 01:02:05 2007
@@ -93,6 +93,7 @@
"""
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 @@
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 @@
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"
More information about the Python-checkins
mailing list