Serious problem with Shelve

Skip Montanaro skip at pobox.com
Tue Aug 19 10:56:57 EDT 2003


    Rami> Well - I installed Python 2.3, but it still doesn't.  My program
    Rami> now crashes on the first pass.  After deleting the old databases
    Rami> and creating new ones, I opened them for read and this is what I
    Rami> get:

How did you create those new databases, using an older version of Python
perhaps?  What's happening is that whichdb.whichdb() determined that the
file you passed into anydbm.open() was an old hash style database, which can
only be opened in Python 2.3 by the old v 1.85 library, which is only
exposed through the bsddb185 module.

    Rami> I will try enclosing that import bsddb185 in anydbm.py in try:
    Rami> except:, though I hate messing around with source files, and there
    Rami> may be many more such problems.  Python developers, be aware of
    Rami> this glitch.

That won't work.  What's anydbm.open() going to use to open the file?

Can you explain how the files were created?  (Sorry if you explained
already.  I'm just coming to this thread.)

If you have Python 2.1 or 2.2 laying around with a bsddb module which can
read the file in question, use Tools/scripts/db2pickle.py to convert the
file to a pickle, then with Python 2.3, run Tools/scripts/pickle2db.py to
convert the pickle back to a db file, using the new bsddb.  Those two
scripts are in the Python 2.3 distribution, but not the Python 2.2
distribution.  They should work with Python 2.1 or 2.2, however.  This
problem is exactly why I wrote them.

Synopsis:

    python2.2 db2pickle.py olddbfile pickle.pck
    python2.3 pickle2db.py newdbfile pickle.pck

Skip





More information about the Python-list mailing list