Issue1007

classification
Title: pickling of a class derived from dict delivers only empty dicts
Type: behaviour Severity: normal
Components: Library Versions: 2.2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: PBlitz, fwierzbicki, john.jython, pjenvey
Priority: low Keywords:

Created on 2008-03-11.13:23:21 by PBlitz, last changed 2009-06-21.22:00:47 by pjenvey.

Messages
msg3083 (view) Author: (PBlitz) Date: 2008-03-11.13:23:20
Pickling of a class derived from dict creates an empty pickle in jython
2.2.1. In contrast Python 2.5.2 delivers the expected result.
I dont know how to solve the problem. 

# code:

from __future__ import generators

class MyDict(dict): 
    def __init__(self, d = None):
        if d == None: d = {}
        dict.__init__(d)

if __name__ == "__main__":
    import pickle    
           
    dd = MyDict()
    dd['z'] = [0,1]
    dd['b'] = [2,3]
    p = pickle.dumps(dd)
    print "-> pickle p:\n", p
    u = pickle.loads(p)
    print "-> MyDict dd:\n", dd
    print "-> reconstructed MyDict u:\n", u

# jython 2.2.1 output with empty pickle p:

-> pickle p:
c__main__
MyDict
p0
(tp1
Rp2
.
-> MyDict dd:
{'b': [2, 3], 'z': [0, 1]}
-> reconstructed MyDict u:
{}

# in contrast python 2.5.2 output with filled pickle p:

-> pickle p:
ccopy_reg
_reconstructor
p0
(c__main__
MyDict
p1
c__builtin__
dict
p2
(dp3
S'z'
p4
(lp5
I0
aI1
asS'b'
p6
(lp7
I2
aI3
astp8
Rp9
.
-> MyDict dd:
{'z': [0, 1], 'b': [2, 3]}
-> reconstructed MyDict u:
{'z': [0, 1], 'b': [2, 3]}
msg3091 (view) Author: John Sirbu (john.jython) Date: 2008-03-17.20:39:51
Trunk in development has the appropriate and associated fix. 

Just a heads up, hash/key order can vary across platforms and jvms.
msg3948 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-12-17.15:01:04
Works in 2.5, but we probably want to look at this for 2.2.2.
msg4838 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-21.22:00:47
fixed in 2.5
History
Date User Action Args
2009-06-21 22:00:47pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4838
nosy: + pjenvey
2009-03-14 03:13:05fwierzbickisetversions: + 2.2.2, - 2.2rc3
2008-12-17 15:01:04fwierzbickisetpriority: low
messages: + msg3948
2008-03-17 20:39:52john.jythonsetnosy: + john.jython
messages: + msg3091
2008-03-11 18:24:21fwierzbickisetnosy: + fwierzbicki
2008-03-11 13:31:48PBlitzsettitle: pickling of a class derived from dict is empty -> pickling of a class derived from dict delivers only empty dicts
2008-03-11 13:23:21PBlitzcreate