[ python-Bugs-1699759 ] pickle example contains errors
SourceForge.net
noreply at sourceforge.net
Thu Apr 19 09:00:06 CEST 2007
Bugs item #1699759, was opened at 2007-04-13 02:22
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1699759&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mark Edgington (edgimar)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: pickle example contains errors
Initial Comment:
In the pickle documentation (see http://docs.python.org/lib/pickle-example.html ), 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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1699759&group_id=5470
More information about the Python-bugs-list
mailing list