Pickle translation
Fredrik Lundh
fredrik at pythonware.com
Thu Jul 12 11:35:19 EDT 2001
Skip Montanaro wrote:
> Interpretation of \x escapes was tightened up in 2.0 I believe. In versions
> earlier than 2.0 '\xyy' is interpreted as the four-character sequence:
>
> \ x y y
not if yy is hexadecimal digits. the difference is that in 1.5.2, \x
could consume more than 2 hex digits.
> In 2.0 and 2.1 the ValueError you see is raised because "yy" can't be
> interpreted as a hex number.
shouldn't happen, though: pickle uses repr, and repr didn't ever
create \x escapes in 1.5.2.
you could get this problem if you move text pickles from 2.1 back to
1.5.2, though: "\x1234" is one character under 1.5.2, three under 2.0
and later. and 2.1's repr uses \xnn instead of \ddd on output...
> I'm not sure what the solution is. Someone with more pickle/string/
> internals knowledge will probably have some ideas.
one possible workaround could be to load the pickle under 1.5.2,
and write it out as a binary pickle:
infile = open("data")
object = pickle.load(infile)
outfile = open("outdata", "wb")
pickle.dump(object, outfile, 1)
outfile.close()
</F>
More information about the Python-list
mailing list