[issue13505] Bytes objects pickled in 3.x with protocol <=2 are unpickled incorrectly in 2.x
sbt
report at bugs.python.org
Mon Dec 12 22:45:13 CET 2011
sbt <shibturn at gmail.com> added the comment:
I now realise latin_1_encode won't work because it returns a pair (bytes_obj, length).
I have done a patch using _codecs.encode instead -- the pickles turn out to be exactly the same size anyway.
>>> pickletools.dis(pickle.dumps(b"abc", 2))
0: \x80 PROTO 2
2: c GLOBAL '_codecs encode'
18: q BINPUT 0
20: X BINUNICODE 'abc'
28: q BINPUT 1
30: X BINUNICODE 'latin1'
41: q BINPUT 2
43: \x86 TUPLE2
44: q BINPUT 3
46: R REDUCE
47: q BINPUT 4
49: . STOP
----------
Added file: http://bugs.python.org/file23938/issue13505-codecs-encode.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13505>
_______________________________________
More information about the Python-bugs-list
mailing list