infinite recursion in pickle.load()

Discussion in 'Python' started by Thomas, Jul 1, 2009.

  1. Thomas

    Thomas Guest

    we regularly pickle and unpickle data from the same script (mostly
    dictionaries).

    sometimes, a file written this way cannot be unpickled with
    pickle.load(), due to an infinite recursion with __getattr__ in
    codecs.py. here is a python2.5 stack trace excerpt:

    /usr/local/lib/python2.5/pickle.py in load(file)
    1403
    1404 def load(file):
    -> 1405 return Unpickler(file).load()
    1406
    1407 def loads(str):

    /usr/local/lib/python2.5/pickle.py in load(self)
    891 while 1:
    892 key = read(1)
    --> 893 dispatch[key](self)
    894 except _Stop, stopinst:
    895 return stopinst.value

    /usr/local/lib/python2.5/pickle.py in load_build(self)
    1248 state = stack.pop()
    1249 inst = stack[-1]
    -> 1250 setstate = getattr(inst, "__setstate__", None)
    1251 if setstate:
    1252 setstate(state)

    /usr/local/lib/python2.5/codecs.py in __getattr__(self, name, getattr)
    328 """ Inherit all other methods from the underlying stream.
    329 """
    --> 330 return getattr(self.stream, name)
    331
    332 def __enter__(self):

    /usr/local/lib/python2.5/codecs.py in __getattr__(self, name, getattr)
    328 """ Inherit all other methods from the underlying stream.
    329 """
    --> 330 return getattr(self.stream, name)
    331
    332 def __enter__(self):

    ...

    The last frame repeats ad infinitum.

    'inst' in the third frame is a <StreamWriter instance at 839b62c>

    The problem is the same with cPickle.

    This looks somewhat related to this Python issue, which is only about
    the exception reporting:
    http://bugs.python.org/issue5508
    (The title of the issue is the error you get when running our code in
    python2.6).

    Any idea how to go about that?

    T.
     
    Thomas, Jul 1, 2009
    #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. GB
    Replies:
    0
    Views:
    407
  2. a pickle's pickle

    , Aug 2, 2005, in forum: Python
    Replies:
    4
    Views:
    393
  3. Orest Kozyar
    Replies:
    5
    Views:
    369
    Paul Boddie
    Nov 1, 2007
  4. -dresden.de
    Replies:
    2
    Views:
    513
    Peter Otten
    Mar 12, 2008
  5. Michele Simionato
    Replies:
    2
    Views:
    1,909
    Michele Simionato
    May 23, 2008
Loading...

Share This Page