[issue5518] cPickle produces inconsistent output

rb report at bugs.python.org
Thu Mar 19 16:53:52 CET 2009


New submission from rb <rb-oss-2 at justgohome.co.uk>:

The documentation states that the output of pickle and cPickle may be
different. However it is implied that the output of a particular module
will always be consistent within itself. This expectation fails for the
case below.

I am using the output of cPickle in order to generate a key to use for
external storage where the key is abstracted to a generic Python
(immutable) object. Without consistency this breaks for me; pickle is
too slow so I need to use cPickle.

$ python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle
>>> key = (1, u'foo')
>>> cPickle.dumps(key)
'(I1\nVfoo\ntp1\n.'
>>> cPickle.dumps((1, u'foo'))
'(I1\nVfoo\np1\ntp2\n.'

PythonWin 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] 
on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for 
further copyright information.
>>> import cPickle
>>> key = (1,u'foo')
>>> cPickle.dumps(key)
'(I1\nVfoo\ntp1\n.'
>>> cPickle.dumps((1,u'foo'))
'(I1\nVfoo\np1\ntp2\n.'

Expected results: the output of the two dumps calls should be the same.

----------
components: Library (Lib)
messages: 83814
nosy: rb
severity: normal
status: open
title: cPickle produces inconsistent output
versions: Python 2.5, Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5518>
_______________________________________


More information about the Python-bugs-list mailing list