pickle magically not working
Michael Janssen
Janssen at rz.uni-frankfurt.de
Mon Sep 16 18:39:40 EDT 2002
Hello
at least i've solved it (as a workaround), but it's pretty annoying.
Maybe someone has an answere :-)
i wanted to pickle a dictionary. The code was fine on my own maschine
but throwing RuntimeError: "maximum recursion depth exceeded" on other
maschines (same Linux, same Python-Version 2.2).
The mindthrilling thing was (and is), that i can copy the dictionary
content with mouse2 into a working dictionary. Original dic still
refused working. Have a look:
m is a single-key version of the bad dic. mm is hand-made
>>> m == mm
1
>>> m
{(2002, 9, 16, 0, 0, 0, 0, 259, 1): {'virus': 1, 'batches': 186,
'scan': 152, 'mail': 307, 'spam': 0, 'bytes': 6213773}}
>>> mm
{(2002, 9, 16, 0, 0, 0, 0, 259, 1): {'virus': 1, 'batches': 186,
'spam': 0, 'mail': 307, 'scan': 152, 'bytes': 6213773}}
>>> try: pickle.dump(m, fo); print "functional"
... except RuntimeError: print "not functional"
...
not functional
>>> try: pickle.dump(mm, fo); print "functional"
... except RuntimeError: print "not functional"
...
functional
copy.copy or copiing via:
d = {}
for key in dump_dic.keys():
d[key] = dump_dic[key]
doesn't help. finally i've improved ;-) the copiing-code to:
d = {}
for key in dump_dic.keys():
d[key[:]] = dump_dic[key]
i.e. making copies of the keys (which are tupel as returned by
time.localtime(), by the way).
Pickling is now functional, but the question remains:
*what can cause this???*
Furthermore: is there a way to examine somewhat deep data-structure, or
is it more reliable to blame voodoo and "computer-logik" for this ;-)
Michael
PS: Don't ask me, how i've build those nasty dics. Hundreds lines of
slightly confused code have done it ;-)
More information about the Python-list
mailing list