Title: pickle example contains errors
Type: Stage:
Components: Documentation Versions:
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: edgimar, georg.brandl, rhettinger
Priority: normal Keywords:

Created on 2007-04-13 07:22 by edgimar, last changed 2007-08-23 21:25 by georg.brandl. This issue is now closed.

Messages (2)
msg31769 - (view) Author: Mark Edgington (edgimar) Date: 2007-04-13 07:22
In the pickle documentation (see ), there is an error.  At the end of the page, under the "A sample usage might be..." section, the file for dumping is opened in text-mode instead of binary mode.

This bit me because I was lazy and didn't re-read all of the pickle documentation, but based some code on this snippet.  The problem occurs under certain circumstances when pickling a type 'object' instance (newstyle) under Windows, and then attempting to unpickle it under Linux.  You get the following error: ImportError: No module named copy_reg.  This made no sense to me, and it took a long time to figure out that the problem was due to the mode in which the file was saved (what that has to do with the ImportError I still have no idea...).  If interested, I could attach a test script which is supposed to load the data to a class instance, and two pickle dumps, one which works, and the other which fails.

Perhaps a related suggestion which maybe should be in a different bug is that pickle should check to see when it writing to a filehandle if the filehandle's mode is binary or text, and to issue a warning if it is text.
msg55219 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-08-23 21:25
The example is already fixed; also, a note is in the docs that you must
use binary mode for protocols >= 1.
Date User Action Args
2007-08-23 21:25:40georg.brandlsetstatus: open -> closed
resolution: out of date
messages: + msg55219
nosy: + georg.brandl
2007-04-13 07:22:53edgimarcreate