diff options
| author | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-12 18:44:06 (GMT) |
|---|---|---|
| committer | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-12 18:44:06 (GMT) |
| commit | d40f126fffbb05e1f46dff3d2e0f3e8b1938de1c (patch) | |
| tree | e887b6c35ad89eb5bcb9fe72f9c3025bcb223d63 /Lib/bsddb/dbshelve.py | |
| parent | 3a0de08d5468c18ba09443cbe2f3b661ddd775e0 (diff) | |
| download | cpython-d40f126fffbb05e1f46dff3d2e0f3e8b1938de1c.zip cpython-d40f126fffbb05e1f46dff3d2e0f3e8b1938de1c.tar.gz cpython-d40f126fffbb05e1f46dff3d2e0f3e8b1938de1c.tar.bz2 | |
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.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py index 077f9c7..33668f4 100644 --- a/Lib/bsddb/dbshelve.py +++ b/Lib/bsddb/dbshelve.py @@ -84,6 +84,9 @@ def open(filename, flags=db.DB_CREATE, mode=0660, 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. @@ -162,10 +165,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): |
