[Python-bugs-list] [ python-Bugs-751276 ] cPickle doesn't raise error, pickle does (recursiondepth)

SourceForge.net noreply@sourceforge.net
Sat, 14 Jun 2003 12:19:36 -0700


Bugs item #751276, was opened at 2003-06-09 13:13
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=751276&group_id=5470

Category: Python Library
Group: None
>Status: Open
Resolution: Wont Fix
Priority: 5
Submitted By: Irmen de Jong (irmen)
Assigned to: Nobody/Anonymous (nobody)
Summary: cPickle doesn't raise error, pickle does (recursiondepth)

Initial Comment:
I have this object that causes a recursive call in the
__getattr__ method.

When I unpicke it using pickle, I get a runtimeerror
recursiondepth exceeded. When I unpickle it using
cPickle, everything appears to work -- no error is raised.
(tested on python 2.2.3 and 2.3b1)

The output of the attached python test file is:

***pickle***
Creating t...
Thing.__init__ name= myname
Pickle t...
Restore t...
FAIL!!!  <exceptions.RuntimeError instance at
0x00951C68> maximum recursion depth exceeded
***cPickle***
Creating t...
Thing.__init__ name= myname
Pickle t...
Restore t...
SUCCESS!!! name= myname


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-06-14 21:19

Message:
Logged In: YES 
user_id=21627

I see. The problem occurs when trying to find __setstate__.
pickle.py uses getattr("setstate", None), which only masks
AttributeError, passing RuntimeError through. cPickle masks
all exceptions. It would be indeed possible to have one
match the other.

Reopening the report. Notice that there are dozens such
inconsistencies, so it will be a sisyphus job to fix them all.

----------------------------------------------------------------------

Comment By: Irmen de Jong (irmen)
Date: 2003-06-14 19:08

Message:
Logged In: YES 
user_id=129426

I fail to understand why this cannot be fixed. Is the
cPickle implementation that different from the pickle one?
In this particular case: it doesn't use __getattr__ the same
way as pickle does, apparently. 

Increasing sys.setrecursionlimit won't help because the
recursion is  infinite.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-06-14 16:23

Message:
Logged In: YES 
user_id=21627

This problem cannot be fixed. cPickle and pickle work
differently by nature; one is written in C, the other in
Python (as their names suggest).

You can try to sys.setrecursionlimit, to raise the nesting
level that pickle.py supports.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=751276&group_id=5470