[Python-Dev] when is binary mode required for pickle? (original) (raw)

Tim Peters tim_one@email.msn.com
Wed, 12 Feb 2003 22:36:59 -0500


Let me simplify this: if you want a surprise-free and portable life, always open pickle files in binary mode, regardless of pickling module (pickle or cPickle), platform, pickle protocol, or whether reading or writing.

And, yes, the docs could be clearer about this.

The downside is that proto 0 (text mode) pickles "look funny" in Notepad on Windows if written to a file opened in binary mode (they don't have the \r\n line endings then that Notepad expects).