summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/dbshelve.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2007-10-12 19:13:19 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2007-10-12 19:13:19 (GMT)
commit5c5f1703e558c9308c9d305f7927bf92e0180c31 (patch)
treea007f43b1b68e8c2c814fa83ed53950ca8bef8a5 /Lib/bsddb/dbshelve.py
parent041683df428a42c8a01b68d79735b75d1d1dc111 (diff)
downloadcpython-5c5f1703e558c9308c9d305f7927bf92e0180c31.zip
cpython-5c5f1703e558c9308c9d305f7927bf92e0180c31.tar.gz
cpython-5c5f1703e558c9308c9d305f7927bf92e0180c31.tar.bz2
Merge r58434:
Fixes http://bugs.python.org/issue1233 - bsddb.dbshelve.DBShelf.append was useless due to inverted logic. Also adds a test case for RECNO dbs to test_dbshelve.
Diffstat (limited to 'Lib/bsddb/dbshelve.py')
-rw-r--r--Lib/bsddb/dbshelve.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py
index 2959f25..c687ab5 100644
--- a/Lib/bsddb/dbshelve.py
+++ b/Lib/bsddb/dbshelve.py
@@ -77,6 +77,9 @@ def open(filename, flags=db.DB_CREATE, mode=0o660, filetype=db.DB_HASH,
#---------------------------------------------------------------------------
+class DBShelveError(db.DBError): pass
+
+
class DBShelf(DictMixin):
"""A shelf to hold pickled objects, built upon a bsddb DB object. It
automatically pickles/unpickles data objects going to/from the DB.
@@ -152,10 +155,10 @@ class DBShelf(DictMixin):
return self.db.append(data, txn)
def append(self, value, txn=None):
- if self.get_type() != db.DB_RECNO:
+ if self.get_type() == db.DB_RECNO:
self.append = self.__append
return self.append(value, txn=txn)
- raise db.DBError("append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO")
+ raise DBShelveError("append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO")
def associate(self, secondaryDB, callback, flags=0):