[Patches] Update bug in dumbdbm.py

Joe Eaton jeaton@hostway.net
Wed, 21 Jun 2000 14:26:43 -0500


I confirm that, to the best of my knowledge and belief, this
                    contribution is free of any claims of third parties
under
                    copyright, patent or other rights or interests
("claims").  To
                    the extent that I have any such claims, I hereby
grant to CNRI a
                    nonexclusive, irrevocable, royalty-free, worldwide
license to
                    reproduce, distribute, perform and/or display
publicly, prepare
                    derivative versions, and otherwise use this
contribution as part
                    of the Python software and its related
documentation, or any
                    derivative versions thereof, at no cost to CNRI or
its licensed
                    users, and to authorize others to do so.

                    I acknowledge that CNRI may, at its sole discretion,
decide
                    whether or not to incorporate this contribution in
the Python
                    software and its related documentation.  I further
grant CNRI
                    permission to use my name and other identifying
information
                    provided to CNRI by me for use in connection with
the Python
                    software and its related documentation.

Hello Patch folks:

There is a silly bug in the fall-back dumbdbm.py database package in the
Python 1.5.2 standard distro.  This bug causes any changes to an
existing item to generate a new key, even when the key already exists.
After many updates, the .dir file used by dumbdbm grows to a huge size,
and can cause filesystem problems.

Here is a simple .py script to give an example:


#!/usr/bin/env python
import shelve
S=shelve.open('Test')
for i in range (2000):
   S['1'] = `i`

This simply replaces the item '1' 2000 times. A look at the file
Test.dir will show 2000 copies of the line
'1' (0, 4)
when just 1 is needed!

The patch for this is:

*** dumbdbm.py  Wed Jun 21 13:07:12 2000
--- /usr/local/python1.5/lib/python1.5/dumbdbm.py       Sun Jan 16
21:01:05 2000
***************
*** 120,125 ****
--- 120,126 ----
                        else:
                                pos, siz = self._addval(val)
                                self._index[key] = pos, siz
-                       self._addkey(key, (pos, siz))

        def __delitem__(self, key):
                del self._index[key]

simply remove the _addkey call to prevent extraneous keys from popping
in.
Should save diskspace for alot of people!

Joe