First post, recursive references with pickle.

Discussion in 'Python' started by mark starnes, Nov 10, 2008.

  1. mark starnes

    mark starnes Guest

    Hi everyone, this is my first post to this group, so please be gentle.

    I've written a class which, when I attempt to pickle, gives the error:

    *** RuntimeError: maximum recursion depth exceeded

    Is there a way to make pickle display data about what it's trying
    to do? I'm thinking that if so, the recursive component will be
    immediately visible, easing the bug hunt.

    Any help would be appreciated.

    BR,

    Mark.
     
    mark starnes, Nov 10, 2008
    #1
    1. Advertisements

  2. On Nov 10, 2:23 pm, mark starnes <> wrote:

    > Hi everyone, this is my first post to this group, so please be gentle.
    >
    > I've written a class which, when I attempt to pickle, gives the error:
    >
    > *** RuntimeError: maximum recursion depth exceeded
    >
    > Is there a way to make pickle display data about what it's trying
    > to do?  I'm thinking that if so, the recursive component will be
    > immediately visible, easing the bug hunt.
    >
    > Any help would be appreciated.


    How about commenting out one by one the attributes of the object
    you're trying to pickle until you find the problematic one(s) ?
    Something like:

    class MyClass(object):
    ...
    def __getstate__(self):
    del self.foo
    return self.__dict__

    Then do the same to the class of self.foo, and so on recursively,
    until you find the real culprit.

    HTH,
    George
     
    George Sakkis, Nov 10, 2008
    #2
    1. Advertisements

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. peter
    Replies:
    9
    Views:
    395
    Michael Spencer
    Feb 17, 2005
  2. a pickle's pickle

    , Aug 2, 2005, in forum: Python
    Replies:
    4
    Views:
    613
  3. Replies:
    2
    Views:
    445
  4. Theron NightStar

    first prog - first post

    Theron NightStar, Jul 11, 2005, in forum: C++
    Replies:
    4
    Views:
    456
    Jon Bell
    Jul 14, 2005
  5. n00m
    Replies:
    12
    Views:
    1,314
  6. Michele Simionato
    Replies:
    2
    Views:
    2,212
    Michele Simionato
    May 23, 2008
  7. vamsi
    Replies:
    21
    Views:
    2,439
    Keith Thompson
    Mar 9, 2009
  8. Wolfgang Nádasi-Donner
    Replies:
    0
    Views:
    169
    Wolfgang Nádasi-Donner
    Jun 29, 2006
Loading...