Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > infinite recursion in pickle.load()

Reply
Thread Tools

infinite recursion in pickle.load()

 
 
Thomas
Guest
Posts: n/a
 
      07-01-2009
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
does your compiler / lint catch infinite recursion ? John C++ 1 08-22-2007 01:46 PM
"Resource lookup failed - infinite recursion detected" and Custom Cultures GB ASP .Net 0 07-03-2006 10:39 AM
Tracing, CultureInfo and infinite Recursion GB ASP .Net 0 05-31-2006 12:09 PM
Strange infinite recursion in metaclass's __new__ Jp Calderone Python 2 11-10-2003 07:53 PM
Why doesn't __call__ lead to infinite recursion? Patrick Lioi Python 7 08-19-2003 06:41 PM



Advertisments