[Python-Dev] Pickling problems are hard to debug

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Mar 26 03:13:22 CEST 2006

There seems to be a need for better diagnostics
when pickle encounters something that can't be

Recently when attempting to pickle a rather
large and complicated data structure, I got
the following incomprehensible message:

   cPickle.PicklingError: args[0]
     from __newobj__ args has the wrong class

Trying again with protocol 1 instead of 2,
I get

   TypeError: can't pickle function objects

which I'm *guessing* is because somewhere I've
tried to pickle a nested function or a bound
method. But it still doesn't give me any idea
*which* function I tried to pickle or where
abouts it turns up in the data structure.

Anyone have any ideas how the situation could
be improved? At the very least, it could
include some info about the type and identity
of the offending object.


More information about the Python-Dev mailing list