This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ggenellina
Recipients
Date 2007-05-25.10:29:02
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The culprit is cPickle.c; it takes certain shortcuts for read() and readline() depending on which type of file you pass in.
For a true file object, it uses its own implementation for those two methods, ignoring the file mode.

But it appears that there is NO WAY universal line endings could work if the pickle contains any unicode object. The pickle format for Unicode quotes any \n but *not* \r so the unpickler cannot determine, when it sees a "\r", if it is a MAC end-of-line or an embedded "\r".
So, the only safe end-of-line character for a pickle using protocol 0 is "\n", and that means that the file must be written in binary mode.
(This may also indicate that you cannot read unicode objects with embedded \r in a MAC using protocol 0, but I don't have a MAC to test it).

So, until this is fixed (either the module or the documentation), one should forget about universal line endings and write all pickle files as binary. (This way ALL lines end in \n and it should work fine on all platforms)
History
Date User Action Args
2007-08-23 14:54:06adminlinkissue1724366 messages
2007-08-23 14:54:06admincreate