Message1234

Author rabidechidna
Recipients
Date 2006-09-19.22:50:43
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I notice that [1530257] "Jython 2.2 cannot pickle types" has been 
closed with the comment "This is fixed in trunk", however when I 
compile the SVN head (revision 2942) I still get errors:

Test file: picklebug.py
================
import cPickle
import traceback

class SimpleObj(object):
    pass

def ptest(x):
    try:
        print "PICKLING", x
        cPickle.dumps(x)
    except:
        traceback.print_exc()
        result = None
        
ptest(int)
ptest(SimpleObj())
ptest(SimpleObj)
================

When I run this  test, it seems that cPickle is mistakenly attempting to 
call the __reduce__ method on the class object:

~% ~/jython/jythonHead picklebug.py 
PICKLING <type 'int'>
Traceback (most recent call last):
  File "picklebug.py", line 10, in ptest
    cPickle.dumps(x)
TypeError: descriptor '__reduce__' of 'int' object needs an argument
PICKLING <__main__.SimpleObj object 1>
Traceback (most recent call last):
  File "picklebug.py", line 10, in ptest
    cPickle.dumps(x)
TypeError: descriptor '__reduce__' of 'object' object needs an argument
PICKLING <class '__main__.SimpleObj'>
Traceback (most recent call last):
  File "picklebug.py", line 10, in ptest
    cPickle.dumps(x)
TypeError: descriptor '__reduce__' of 'object' object needs an argument


The attached patch fixes the problem.

History
Date User Action Args
2008-02-20 17:17:33adminlinkissue1561793 messages
2008-02-20 17:17:33admincreate