Troubleshooting pickle errors

Discussion in 'Python' started by Jean-Luc, Apr 2, 2004.

  1. Jean-Luc

    Jean-Luc Guest

    Hi

    I am grafing pickling functionality on a big dictionary of object
    instances and I am having numerous problems. I think understand the
    notion of what can/can't be pickled and I know how to use __getstate__
    / __setstate__ to weed out offending references. But I am finding it
    very hard to identify _which_ reference is causing exceptions like:

    File "C:\UserApps\Python23\Lib\copy_reg.py", line 69, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
    TypeError: can't pickle function objects

    PrettyPrinting the exception gets me:

    {'args': ("can't pickle function objects",)}.

    The exception includes no references to the guilty party! How do I
    know _which_ object caused the issue? Though my current objects (i.e.
    the stuff I am trying to pickle) are new, its instances hold
    references to a lot of instances of existing utility classes of mine
    that are database aware. I would not like to modify those utility
    classes any more than I _have_ to since I use them elsewhere. I have
    already stripped out database Connection references, as well as File
    references. Those were obvious.

    How do I identify the remaining issues? If I work with a smaller data
    set, I often miss problems entirely, so reducing the pickling scope is
    not an easy option to implement. The best I have managed so far is to
    open the pickle file and look near the end, where the exception
    presumably occurred. But I would expect there to be a more obvious
    way to troubleshoot this stuff.

    Cheers

    JLuc
    Jean-Luc, Apr 2, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    921
    Mark Goldin
    Jan 17, 2004
  2. Jonathan Brandmeyer

    troubleshooting multiple inheritance errors

    Jonathan Brandmeyer, Sep 11, 2004, in forum: Python
    Replies:
    0
    Views:
    272
    Jonathan Brandmeyer
    Sep 11, 2004
  3. a pickle's pickle

    , Aug 2, 2005, in forum: Python
    Replies:
    4
    Views:
    368
  4. Michele Simionato
    Replies:
    2
    Views:
    1,858
    Michele Simionato
    May 23, 2008
  5. Dan

    Pickle Encoding Errors

    Dan, Sep 20, 2009, in forum: Python
    Replies:
    2
    Views:
    734
    Laszlo Nagy
    Sep 21, 2009
Loading...

Share This Page