Why does pickle use eval for loading string values?

Tim Peters tim.one at home.com
Fri Jan 11 00:11:37 EST 2002


[Brian Kelley]
> Here's something I never quite understood.  pickle and cPickle use eval
> to load string values.  This seems fairly neat but why is it necessary?

Mike Fletcher explained it:  it's to process the escape sequences in the
string.  Pickled versions of strings don't contain control characters or
high-bit-set bytes; those get transformed into 7-bit escape sequences that
the unpickler has to undo.

> ...
> I'm tempted to report this as a bug in pickle since interning strings is
> a undocumented side-effect.

If that bothers you, and you don't open a report on it, you can be almost
certain the behavior will never change.  If you do open a report, your
chance of satisfiction zooms to something above 0% <wink>.





More information about the Python-list mailing list