[Python-3000] pickle compatibility between 2.x and 3.0

Alexandre Vassalotti alexandre at peadrop.com
Sat Nov 3 17:07:57 CET 2007

On 11/1/07, Guido van Rossum <guido at python.org> wrote:
> When 3.0 encounters a 'str' object in a pickle written by 2.x, it has
> two choices: trying to convert it to a 3.0 (unicode) str object by
> applying some encoding, or interpreting it as a 3.0 bytes object.

Currently, pickle decodes old string objects using latin-1. To me,
these seems to be a reasonable default (IMHO,
sys.getfilesystemencoding() would be slightly better). However, having
a default encoding might hide decoding errors. So, it may be a better
idea to simply return bytes by default and leave it to the application
to specify the encoding in the unpickling call.

-- Alexandre

More information about the Python-3000 mailing list