[Python-bugs-list] [ python-Bugs-755087 ] anydbm and whichdb one more time

SourceForge.net noreply@sourceforge.net
Sun, 15 Jun 2003 18:26:45 -0700


Bugs item #755087, was opened at 2003-06-16 11:26
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=755087&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Gregory Saunders (grerfy)
Assigned to: Nobody/Anonymous (nobody)
Summary: anydbm and whichdb one more time

Initial Comment:
Bug #744687 was recently closed with an update to the
whichdb.py file. The update fixes the main problem
described in bug 744687, but a tangental problem,
mentioned in 744687, still occurs. The following python
transcript illustrates the problem (it uses the new
whichdb.py file):

---
Python 2.2.2 (#1, Mar 21 2003, 23:01:54) 
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import whichdb, anydbm, dumbdbm
>>> a = dumbdbm.open('/tmp/a', 'c')
>>> a.close()
>>> b = anydbm.open('/tmp/a', 'w')
>>> b['abc'] = 'def'
>>> b.close()
>>> c = anydbm.open('/tmp/a', 'w')
>>> del c['abc']
>>> c.close()
>>> d = anydbm.open('/tmp/a', 'w')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.2/anydbm.py", line 80, in open
    raise error, "need 'c' or 'n' flag to open new db"
anydbm.error: need 'c' or 'n' flag to open new db
>>> 
---

As can be seen, the change to whichdb.py correctly
detects if the dumbdbm database is created, closed, and
re-opened. However, if the dumbdbm file is populated
with some data, then all that data is removed, the bug
once again rears its ugly head. This occurs because
once data is entered into a dumbdbm database, it is
never removed from the .dat file, only the relevant
entry from the .dir file is removed. I suppose the
correct solution to this is to change the
implementation of dumbdbm. A quicker solution, however,
would be a minor change to the new whichdb.py file to
detect only if the .dir file is empty - a patch is
attached.

regards
Greg


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=755087&group_id=5470