This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: bsddb btree set_location() semantics changed
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: gregory.p.smith
Priority: normal Keywords:

Created on 2003-08-13 23:21 by gregory.p.smith, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (3)
msg17747 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2003-08-13 23:21
In the old bsddb module a bsddb.btopen(..) database
would return the next available key+value on a
set_location(key) call when key did not exist in the
database.  In python 2.3 (pybsddb) it raises an
exception and leaves the cursor at an unknown position
in the database.

[reported by Anthony McDonaly on comp.lang.python]

>>> import os
>>> import bsddb
>>> os.chdir('/tmp')
>>> my_data = bsddb.btopen('testing', 'c')
>>> for i in range(10):
...   if i == 5:
...     pass
...   else:
...     my_data['%d'%i] = '%d'%(i*i)
...
>>> my_data.keys()
['0', '1', '2', '3', '4', '6', '7', '8', '9']
>>> my_data.sync()
>>> my_data.set_location('5')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/space/python-2.3/lib/python2.3/bsddb/__init__.py",
line 117, in set_location
    return self.dbc.set(key)
_bsddb.DBNotFoundError: (-30991, 'DB_NOTFOUND: No
matching key/data pair found')

Correct behaviour would have been to return ('6', '36')
msg17748 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2004-02-26 10:11
Logged In: YES 
user_id=413

Yes this is a bug.  The set_location() method should have been calling set_range() rather than set() internally.

Fixing that exposed another bug: set_range() would crash when looking up a key that exists in hash or rn databases.

Both bugs have been fixed to fix this one in python 2.4 & pybsddb CVS.

This bugfix should go into python 2.3.4.
msg17749 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2004-03-16 07:59
Logged In: YES 
user_id=413

committed fix to head and release23-maint along with an associated fix for set_range where it could free() memory that it doesn't own on non B-Tree databases.
History
Date User Action Args
2022-04-10 16:10:38adminsetgithub: 39062
2003-08-13 23:21:08gregory.p.smithcreate