Frustrating segfaults with Shelf

Edward Grefenstette egrefen at gmail.com
Mon Sep 13 13:05:38 EDT 2010


Dear Pythonistas,

Below is a simple script that reads relations from a generator
(they're just tuples of strings) and attempts to write them to a
database. It's simple as hell, and if I simply ignore the database and
have it print to stdout by replacing the line "depsDB[str(index)] =
rels" with "print rels" it works just fine. However every time I try
to run it just inexplicably segfaults. Help, anyone?

Best,
Edward

========================================

from WNvectorBuilder import relBuilder
import sys
import cPickle as pickle
import shelve

def main(argv):

    ## read filenames from command line arguments
    depsFile = open(argv[1])
    lemmaFile = open(argv[2])
    depsDB = shelve.open(argv[3],"c")

    ## load lemma dictionary from lemma file
    lemmaDict = pickle.load(lemmaFile)

    ## index of database entries
    index = 0

    ## read relations from relation generator, write each relation to
database under new index
    for rels in relBuilder(depsFile,lemmaDict):
        index += 1
        depsDB[str(index)] = rels
        del rels

if __name__ == '__main__':
    main(sys.argv)

========================================



More information about the Python-list mailing list