utility to display the contents of a pickle

Lulu of the Lotus-Eaters mertz at gnosis.cx
Sat Oct 14 19:23:58 EDT 2000


From: "Tom" <nospam at nospam.com>
| I had in mind a utility that would display the contents of a pickle file w/o
| unpickling.  Sort of like:
| Instance (module a, class b)
|     Integer: 125
|     Tuple: [1,2,3]
|     Instance (module a, class b)
|         String: 'blah'
| This would be for occasions when you can't unpickle.  This is happening to
| me rather frequently, and the error messages I get from the unpickler are
| very cryptic.

Well... the representation created by my utility function is very
similar to the above example...  However, as mentioned, you need to be
able to unpickle to get there (or start from an in-memory object).

I rather wonder why you have so much trouble with unpickling though.
Are the pickle files becoming corrupt?  Are you somehow finding a type
of object that won't pickle correctly (unlikely, I think, but maybe)?

In the case of corruption, I suppose some kind of scheme with ECC (error
correcting codes) might be a possibility.  I suppose I can also offer
the suggestion of another module of mine, xml_pickle, that produces a
much more readable pickled representation to start with (much more
slowly than the real pickle, with files many times as large).

Of course, that is not to say that you couldn't figure out the actual
bytecode encodings of pickle (or that someone hasn't done exactly what
you want).  But I think the problem of not being able to unpickle
represents something more serious going on.

Yours, Lulu...




More information about the Python-list mailing list