[Spambayes] Alpha 2 Release?

Skip Montanaro skip at pobox.com
Thu Jan 30 14:41:32 EST 2003


    >>> Side remark:
    >>> On MacOS X, upgrading from 2.2 to 2.3 changes the default database
    >>> format.
    >> 
    >> IIRC, 2.3 includes db3.  So "best" would change for you.

    Francois> And then I can't access my existing one ;-)

I'm skeptical that the 2.2 -> 2.3 change is what nailed your database.  I've
been using the HEAD branch of Python CVS as my daily Python interpreter
since well before bsddb3 replaced the old bsddb module.  I had no problems
with database files at the transition point.

More likely, what happened sometime between when you started using 2.2 and
when you started using 2.3 is the the underlying Berkeley DB library got
updated.  Unfortunately, the file(1) command on Mac OS X doesn't grok that
file format, so you have to be a bit sneaky to figure out what happened.

On my system, /usr/bin/python is python2.2.  Its bsddb.so file is in
/usr/lib/python2.2/lib-dynload.  "otool -L bsddb.so" tells me:

    bsddb.so:
            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 60.0.0)

This suggests that the Berkeley DB library is bundled in /usr/lib/libSystem.

However, the bsddb.so for Python 2.3 is

    bsddb.so:
            /sw/lib/libdb-3.3.dylib (compatibility version 3.3.0, current version 3.3.11)
            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 60.2.0)

If you find the appropriate versions of bsddb.so for your two Python
versions, so they disagree in this fashion about Berkeley DB?

Sleepycat provided a fairly simple way out of the woods here.  They provide
db_dump and db_load commands with each version of their library.  These
tools transfer databases out of and back into the binary format
(respectively) using a platform-neutral plain text format.  You'd db_dump
with the version of db_dump compatible with your old library, then db_load
using the version compatible with your new library.  Unfortunately, it
appears Apple saw fit not to deliver them with Mac OS X.  (I got them with
the fink distribution, so only have libdb3.3 versions at the moment.)

All is still not lost, however.  Assuming you have both 2.2 and 2.3
available, you can try something like the following (untested!) code.

Run this with Python 2.2:

    #!/usr/bin/python

    import bsddb
    db = bsddb.hashopen("hammie.db")
    f = open("hammie.txt", "w")
    for key in db.keys():
        f.write('%s\n" % (key, db[k]))
    db.close()
    f.close()

Run this with Python 2.3:

    #!/usr/local/bin/python2.3

    import bsddb
    db = bsddb.hashopen("hammie.db.new", "c")
    for line in open("hammie.txt"):
        key, val = eval(line)
        db[key] = val
    db.close()

Now, replace hammie.db file with hammie.db.new:

    mv hammie.db hammie.db.save
    chmod 444 hammie.db.save
    mv hammie.db.new hammie.db

and see if Spambayes works for you using 2.3.

Skip



More information about the Spambayes mailing list