[Python-Dev] [ 654866 ] pickle and cPickle not equivalent

Patrick K. O'Brien pobrien@orbtech.com
Mon, 16 Dec 2002 16:09:03 -0600


--------------Boundary-00=_37G8NHCY5EHYZUUF98V5
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 8bit

I'd like to call attention to a bug report I just submitted to SF 
concerning a potentially serious problem with the c-version of pickle.

In short, I think I discovered a situation where cPickle is not doing 
the right thing in terms of storing a reference to a previously pickled 
class instance (using Pickler, of course). It looks like its doing a 
put of a new instance, then a get of the original instances dictionary, 
rather than a get of the original instance. On the other hand, pickle 
does the right thing.

I think this is a pretty serious problem, but I'm out of my league when 
it comes to debugging the c-version of pickle. I'm also basing my 
assessment on a minimal understanding of the pickle source code 
combined with looking at two pickle files, one created using pickle, 
the other using cPickle, with no other changes to the program that 
produced them. I understand that cosmetic differences are to be 
expected. But the difference I see is more substantial.

I attached the two pickle files to the SF bug report, but I can't tell 
if they got through so I'm attaching them here as well. If anyone can 
help track this down, I'd really appreciate it. If more detail is 
needed, or a simple code example would help, I'll be happy to do that.

Thanks.

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------

--------------Boundary-00=_37G8NHCY5EHYZUUF98V5
Content-Type: text/plain;
  charset="us-ascii";
  name="cpickle.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cpickle.txt"

(ccopy_reg
_reconstructor
p1
(cpypersyst.clock
Clock
p2
c__builtin__
object
p3
NtRp4
(dp5
S'_ispaused'
p6
I1
sS'_time'
p7
F1039910904.277091
sb(i__main__
Bank
p8
(dp9
S'_nextAccountNumber'
p10
I3
sS'_accounts'
p11
(dp12
I1
(iaccount
Account
(dp13
S'balance'
p14
I0
sS'number'
p15
I1
sbsI2
(iaccount
Account
(dp16
g14
I0
sg15
I2
sbssbtp17
.g1
(ccommands
DepositOrWithdrawal
p18
g3
NtRp19
(dp20
g7
F1039910911.252528
sS'acnt'
p21
(iaccount
Account
p22
g13
bsS'amount'
p23
I555
sb.g1
(g18
g3
NtRp24
(dp25
g7
F1039910918.068189
sg21
g22
sg23
I555
sb.
--------------Boundary-00=_37G8NHCY5EHYZUUF98V5
Content-Type: text/plain;
  charset="us-ascii";
  name="pickle.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="pickle.txt"

(ccopy_reg
_reconstructor
p0
(cpypersyst.clock
Clock
p1
c__builtin__
object
p2
Ntp3
R(dp4
S'_ispaused'
p5
I1
sS'_time'
p6
F1039911604.515402
sbp7
(i__main__
Bank
p8
(dp9
S'_nextAccountNumber'
p10
I3
sS'_accounts'
p11
(dp12
I1
(iaccount
Account
p13
(dp14
S'balance'
p15
I0
sS'number'
p16
I1
sbsI2
(iaccount
Account
p17
(dp18
g15
I0
sg16
I2
sbssbtp19
.g0
(ccommands
DepositOrWithdrawal
p20
g2
Ntp21
R(dp22
g6
F1039911613.244611
sS'acnt'
p23
g13
sS'amount'
p24
I555
sbp25
.g0
(g20
g2
Ntp26
R(dp27
g6
F1039911618.384868
sg23
g13
sg24
I555
sbp28
.
--------------Boundary-00=_37G8NHCY5EHYZUUF98V5--