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 sbt
Recipients alexandre.vassalotti, irmen, meador.inge, pitrou, sbt
Date 2011-12-09.13:31:16
SpamBayes Score 3.6014525e-12
Marked as misclassified No
Message-id <1323437477.44.0.583799811722.issue13505@psf.upfronthosting.co.za>
In-reply-to
Content
> sbt, the bug is not that the encoding is inefficient. The problem is we 
> cannot unpickle bytes streams from Python 3 using Python 2.

Ah.  Well you can do it using codecs.encode.

Python 3.3.0a0 (default, Dec  8 2011, 17:56:13) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle, codecs
>>>
>>> class MyBytes(bytes):
...     def __reduce__(self):
...         return codecs.encode, (self.decode('latin1'), 'latin1')
...
>>> pickle.dumps(MyBytes(b"hello"), 2)
b'\x80\x02c_codecs\nencode\nq\x00X\x05\x00\x00\x00helloq\x01X\x06\x00\x00\x00latin1q\x02\x86q\x03Rq\x04.'

Actually, I notice that array objects created by Python 3 are not decodable on Python 2.  See Issue 13566.
History
Date User Action Args
2011-12-09 13:31:17sbtsetrecipients: + sbt, irmen, pitrou, alexandre.vassalotti, meador.inge
2011-12-09 13:31:17sbtsetmessageid: <1323437477.44.0.583799811722.issue13505@psf.upfronthosting.co.za>
2011-12-09 13:31:16sbtlinkissue13505 messages
2011-12-09 13:31:16sbtcreate